警告:move_uploaded_file()错误

时间:2015-04-26 20:02:22

标签: php function phpmyadmin

我正在尝试使用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);
}
?>

我一直收到这些错误:

  

警告:move_uploaded_file(images / profile / f3582c5d28.png):无法打开流:第20行的C:\ xampp \ htdocs \ cricket \ user \ edit.php中没有此类文件或目录
  警告:move_uploaded_file():无法在第20行的C:\ xampp \ htdocs \ cricket \ user \ edit.php中将'C:\ xampp \ tmp \ php2857.tmp'移动到'images / profile / f3582c5d28.png'< / p>

1 个答案:

答案 0 :(得分:0)

使用完整路径,即:

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);
}

确保dir C:/xampp/htdocs/hello/user/images/profile/可以通过php写入。

文件和文件夹权限

  

在NTFS卷上,您可以设置文件和安全权限   文件夹。这些权限授予或拒绝对文件的访问权限   文件夹。您可以按以下方式查看文件和文件夹的安全权限   完成以下步骤:

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. 
     

如果权限为灰色,则表示权限是从父对象继承的。