我使用来自tizag的资源创建了一个上传脚本,该脚本返回了一个屏幕错误,但是apache日志中没有错误。
HTML表单
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="90000000" />
Select video to upload:
Please choose a file: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
PHP代码
<?php
$target_path = "/var/www/html/upload/";
$target = $target_path . basename($_FILES['uploadedfile']['name'][0] );
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'] [0], $target_path))
{
echo "The file ". basename( $_FILES['uploadefile']['name'] [0]). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
这不应该是非常难以实现的,但是在apache上没有错误,我很难进行故障排除。我的php知识有限,所以请记住这一点。
亲切的问候,
Mark Couto
答案 0 :(得分:4)
这一行:
$target = $target_path . basename($_FILES['uploadedfile']['name'][0] );
就目前而言,$target
只是一个杂散变量而没有在其他地方使用。
它应该是:
$target_path = $target_path . basename($_FILES['uploadedfile']['name'][0] );
&#34;我使用tizag&#34;
中的资源创建了一个上传脚本
您遵循的Tizag教程不会更改其变量。
他们的例子:
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
另外,['uploadefile']
中的拼写错误应为['uploadedfile']
答案 1 :(得分:0)
首先确保将php配置为允许文件上载。 在你的&#34; php.ini&#34;文件搜索指令,并将其设置为ON,
file_uploads= ON