【发布时间】:2017-06-14 15:19:17
【问题描述】:
我在 php 中上传文件并出现以下错误。
抱歉,上传您的文件时出错。
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
print($target_file);
echo "Sorry, there was an error uploading your file.";
}
我该如何解决这个错误?
【问题讨论】:
-
使用 print_r($_FILES); 进行调试,查看这篇文章:stackoverflow.com/questions/2908700/…
-
Array ( [fileToUpload] => Array ( [name] => origdata_c.n..xlsx [type] => [tmp_name] => [error] => 1 [size] => 0 ) )
-
尝试增加php.ini中的upload_max_filesize,重启服务器并检查。