我们有一个使用 PHP 5.2 的网站,该网站托管在 Windows Plesk 服务器中。现在,在通过PHP上传任何文件时遇到问题。当我们尝试这样做时,我们会遇到以下错误。
There was an error uploading the file, please try again!Error Code:6
upload_tmp_dir的本地值为“ C:\ Inetpub \ vhosts \ xxxxxx.xxx \ httpdocs \ tmp”,主值为“ C:\ Windows \ Temp”。
有人可以建议这些文件夹的权限是什么,还是我们需要检查其他内容以通过PHP修复此上传问题?
这是我用来测试Upload的脚本。
脚本1
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
</form>
</body>
</html>
<?PHP
if(!empty($_FILES['uploaded_file']))
{
$path = "newupload/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['uploaded_file']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!Error Code:". $_FILES['uploaded_file']["error"];;
}
}
?>
脚本2
<?php
echo '<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader">';
echo '<input type="file" name="file" size="50"><input name="_upl" type="submit" id="_upl" value="Upload"></form>';
if( $_POST['_upl'] == "Upload" ) {
if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo '<b>Upload SUKSES !!!</b><br><br>'; }
else { echo '<b>Upload GAGAL !!!</b><br><br>'; }
}
?>
脚本1出现错误“上传文件时出错,请重试!错误代码:6”。脚本2显示上传成功。但是上载的文件丢失了。