我一直在试图将表单中的图片移动到托管在Godaddy上的我的网站的上传文件夹中。但是当使用move_uploaded_file()方法时,我会收到权限被拒绝的错误。我已经阅读了很多关于此主题的问题,但还没有解决我的问题。另外,我已经将权限更改为777。
下面是我一直遇到的错误:
警告: move_uploaded_file() [function.move-uploaded-file]:无法将'D:\Temp\php\php42C0.tmp'移动到'D:\Hosting\11111\html\dir\upload_image\formsubmit.php on line 80'中的'upload/vZvD6WI4vkapbCLovWtrSIG3xPLD0E.jpeg'。
PHP代码:
下面是我一直遇到的错误:
警告: move_uploaded_file() [function.move-uploaded-file]:无法将'D:\Temp\php\php42C0.tmp'移动到'D:\Hosting\11111\html\dir\upload_image\formsubmit.php on line 80'中的'upload/vZvD6WI4vkapbCLovWtrSIG3xPLD0E.jpeg'。
PHP代码:
$name = $_POST['name'];
$email = $_POST['email'];
if(isEmpty($name) || isEmpty($email)) {
print '<b>Please go back to the previous page and fill out your name.</b>';
}
else {
$file_name = "file1";
if ((($_FILES[$file_name]["type"] == "image/gif")
|| ($_FILES[$file_name]["type"] == "image/jpeg")
|| ($_FILES[$file_name]["type"] == "image/jpg")
|| ($_FILES[$file_name]["type"] == "image/bmp")
|| ($_FILES[$file_name]["type"] == "image/tiff")
|| ($_FILES[$file_name]["type"] == "image/png")
|| ($_FILES[$file_name]["type"] == "image/pjpeg"))
&& ( ($_FILES[$file_name]["size"] < 10000000) && $_FILES[$file_name]["size"] > 0) )
{
if ($_FILES[$file_name]["error"] > 0)
{
print "There was an error in uploading your images: " . $_FILES[$file_name]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $rand_img_name.".jpeg") )
{
print "Please try uploading your image again<br />";
}
else
{
move_uploaded_file($_FILES[$file_name]["tmp_name"],
"upload" ."/". $rand_img_name.".jpeg");
$files_are_valid[($i-1)] = true;
}
}
}
else
{
print 'Image must be a valid image under 10 MB (Make sure you submitted an image)<br />';
$files_are_valid[($i-1)] = false;
}
}
if($files_are_valid[0] == true) {
$all_valid = true;
}
else {
$all_valid = false;
}