您好我正在尝试创建一个表单,该表单将按照一些 Web 示例加载图像,但我无法加载图像。我正在开发运行 apache 的个人 Fedora 盒子。是否有一些我必须对 Apache 做不同的设置?这是我应该上传图片的表单脚本:
<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "get">
<table>
<tr>
<th>Title:</th> <td><input type="text" name ="photoname"></td>
</tr>
<tr>
<th>Photograph:</th> <td><input type="file" id="file" name="file" accept="image/*"></td>
</tr>
<tr>
<th>Photographer:</th><td><input type="" name="photographer"></td>
</tr>
<tr>
<th>Genre:</th><td><input type = "" name="genre"></td>
</tr>
<table>
<input type="submit" value = "Submit">
</form>
这是我的 PHP 脚本:
<?php
$uploaddir = '/var/www/html/photodb';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file']['name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
当我通过表单添加图像时,php 表单无法显示“可能的文件上传攻击!” 我猜这意味着文件无法移动或文件未上传?
我这样做是为了我的大学作业,任何回应或其他想法都非常感谢:)。