<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>File Manager</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="nav">
<a href="index.php">View</a> | <a href="upload-file.php">Upload</a>
</div>
<h1>File Manager — Upload Files</h1>
<form enctype="multipart/form-data" action="upload-file.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="50000" />
<p><input type="file" name="uploaded[]"/></p>
<p><input type="file" name="uploaded[]"/></p>
<p><input type="file" name="uploaded[]"/></p>
<p><input type="file" name="uploaded[]"/></p>
<p><input type="file" name="uploaded[]"/></p>
<p><input type="submit" value="Upload" /></p>
</form>
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name'][0]);
$tmpfil = $_FILES['uploaded']['tmp_name'][0];
$ok=1;
if(move_uploaded_file($tmpfil, $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been upload\
ed";
}
else {
echo $target . " WAS TARGET<br/><br/>";
echo $tmpfil . " WAS TEMP<br/><br/>";
print_r($_FILES);
echo "Sorry, there was a problem uploading your file.";
}
?>
</body>
</html>
现在我只是想在我继续之前让第一个上传的工作正常工作,(这就是我索引 0 的原因),但是当我尝试上传图片时会产生这个输出
upload/puppy.jpg WAS TARGET
/var/tmp/php9raOkG WAS TEMP
Array ( [uploaded] => Array ( [name] => Array ( [0] => puppy.jpg [1] => [2] => [3] => [4] => ) [type] => Array ( [0] => image/jpeg [1] => [2] => [3] => [4] => ) [tmp_name] => Array ( [0] => /var/tmp/php9raOkG [1] => [2] => [3] => [4] => ) [error] => Array ( [0] => 0 [1] => 4 [2] => 4 [3] => 4 [4] => 4 ) [size] => Array ( [0] => 15404 [1] => 0 [2] => 0 [3] => 0 [4] => 0 ) ) ) Sorry, there was a problem uploading your file.
我所有的脚本和上传/文件夹都是 chmoded 777,因为我不记得正确的权限是什么,我认为它应该可以工作......
提前致谢!