我试图通过HTML表单上传文件(msword/doc)到Apache服务器文件夹。它在我本地测试(我通过MAMP测试它)时起作用,但是当我将它上传到远程服务器(如GoDaddy)时,它不起作用。它显示“文件上传存在问题”。PHP文件上传(在本地工作,但不在远程服务器上)。
以下是处理文件上传的代码片段。我无法弄清楚我的条件有什么问题。任何想法,将不胜感激!
// Move the file to the target upload folder
$target = FILE_UPLOADPATH . basename($new_file);
if (move_uploaded_file($_FILES['new_file']['tmp_name'], $target))
{
// The new file move was successful, now make sure any old file is deleted
if (!empty($old_file) && ($old_file != $new_file))
{
@unlink(FILE_UPLOADPATH . $old_file);
}
}
else
{
// The new file move failed, so delete the temporary file and set the error flag
@unlink($_FILES['new_file']['tmp_name']);
echo 'There was a problem with the file upload.' . PHP_EOL;
}
您可以分享完整的$ _FILES数组,因为错误参数中的值可能有助于阐明 – fullybaked 2013-04-29 16:05:56
这里是$ _FILES数组输出:Array([new_file] => Array([name] => sample .doc [type] => msword/doc [tmp_name] =>/tmp/phpsTu20P [error] => 0 [size] => 119674))想法? – kthaker 2013-04-29 16:25:15
错误参数中的值为0. – kthaker 2013-04-29 16:28:25