我正在尝试通过 HTML 表单将文件(msword/doc)上传到 Apache 服务器文件夹。当我在本地测试它时它可以工作(我正在通过 MAMP 测试它),但是当我将它上传到远程服务器(例如 GoDaddy)时,它就不起作用了。它显示“文件上传有问题”。
下面是处理文件上传的代码片段。我无法弄清楚我的条件有什么问题。
// 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;
}