警告:move_uploaded_file() 错误
Warning: move_uploaded_file() errors
我正在尝试上传带有 php 相关用户个人资料的个人资料图片,但每次我使用 move_uploaded_file
时,我总是出错,我已经测试了所有标准程序:
这是我使用的代码:
function change_profile_image($row, $file_temp, $file_extn) {
$file_path = 'images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
}
?>
我不断收到这些错误:
Warning: move_uploaded_file(images/profile/f3582c5d28.png): failed to open stream: No such file or directory in C:\xampp\htdocs\cricket\user\edit.php on line 20
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php2857.tmp' to 'images/profile/f3582c5d28.png' in C:\xampp\htdocs\cricket\user\edit.php on line 20
使用完整路径,即:
function change_profile_image($row, $file_temp, $file_extn) {
$file_path = 'C:/xampp/htdocs/hello/user/images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
}
确保 C:/xampp/htdocs/hello/user/images/profile/
目录可由 php 写入。
文件和文件夹权限
On NTFS volumes, you can set security permissions on files and
folders. These permissions grant or deny access to the files and
folders. You can view security permissions for files and folders by
completing the following steps:
In Windows Explorer, right-click the file or folder you want to work with.
From the pop-up menu, select Properties, and then in the Properties dialog box click the Security tab.
In the Name list box, select the user, contact, computer, or group whose permissions you want to view.
If the permissions are dimmed, it means the permissions are inherited from a parent object.
我正在尝试上传带有 php 相关用户个人资料的个人资料图片,但每次我使用 move_uploaded_file
时,我总是出错,我已经测试了所有标准程序:
这是我使用的代码:
function change_profile_image($row, $file_temp, $file_extn) {
$file_path = 'images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
}
?>
我不断收到这些错误:
Warning: move_uploaded_file(images/profile/f3582c5d28.png): failed to open stream: No such file or directory in C:\xampp\htdocs\cricket\user\edit.php on line 20
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php2857.tmp' to 'images/profile/f3582c5d28.png' in C:\xampp\htdocs\cricket\user\edit.php on line 20
使用完整路径,即:
function change_profile_image($row, $file_temp, $file_extn) {
$file_path = 'C:/xampp/htdocs/hello/user/images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
}
确保 C:/xampp/htdocs/hello/user/images/profile/
目录可由 php 写入。
文件和文件夹权限
On NTFS volumes, you can set security permissions on files and folders. These permissions grant or deny access to the files and folders. You can view security permissions for files and folders by completing the following steps:
In Windows Explorer, right-click the file or folder you want to work with. From the pop-up menu, select Properties, and then in the Properties dialog box click the Security tab. In the Name list box, select the user, contact, computer, or group whose permissions you want to view.
If the permissions are dimmed, it means the permissions are inherited from a parent object.