我一直在尝试将图像从表单移动到我网站上的上传文件夹,该文件夹由 godaddy 托管。使用 move_uploaded_file() 方法时,我收到权限被拒绝错误。关于这个主题,我已经解决了很多问题,但没有一个问题能解决我的问题。另外,我已将权限更改为 777。
这是我得到的错误:
警告:move_uploaded_file() [function.move-uploaded-file]:无法将 'D:\Temp\php\php42C0.tmp' 移动到 D:\Hosting\11111\html\dir\ 中的 'upload/vZvD6WI4vkapbCLovWtrSIG3xPLD0E.jpeg'第 80 行的 upload_image\formsubmit.php
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;
}