$ _FILES不为空,但move_uploaded_file返回false [英] $_FILES is not empty but move_uploaded_file returns false
问题描述
我有问题.几个小时以来,我试图使上传脚本正常工作.我还阅读了有关stackoverflow的其他问题,但无济于事.Webspace允许file_upload,并且文件的大小不能太大.也存在将下载内容移动到的目录.我的html代码是:
I have a problem. Since hours I try to get a upload script working. I also read some other questions on stackoverflow but nothing helped. The webspace allows file_upload and the size of the file is not too large. The directory where to move the downloads exists, too. My html code is:
Upload: <input type="file" name="file">
我的PHP代码是:
if ($_FILES['file']['error'] == 0) {
$tmp_name = $_FILES["file"]["tmp_name"];
$name_file = $_FILES["file"]["name"];
move_uploaded_file($tmp_name, "upload/" . $name_file);
}
我回显了$ _FILES,文件在那里,没有错误.每次我尝试上传文件时(我也尝试上传其他文件和文件类型)move_uploaded_file返回false.
I echoed $_FILES and the file was in there and there was no error. Everytime I try to upload the file (I also tried to upload other files and file types) move_uploaded_file returned false.
该文件夹现在可写.
推荐答案
好的,我解决了我的问题.我启用了 error_resporting()
,并且由于未设置权限的任何原因.现在它们是777,我可以移动文件了.
Okay, I solved my problem. I enabled error_resporting()
and because any reason the permissions weren't set. Now they are 777 and I can move the files.
这篇关于$ _FILES不为空,但move_uploaded_file返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!