这是我upload.php的文件 这里是代码注意:未定义指数:文件C: XAMPP htdocs中项目上传 upload.php的第6行
<?php
include_once 'dbh.php';
$target_dir = "project/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["file"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
?>
这是我的HTML代码
<form action="upload.php" method="post" enctype="multipart/form-data">
<label class="custom-file-input" for="file" >
</label>
<input id="file" type="file" multiple="multiple" name="file" accept="image/*" style="visibility: hidden">
</form>
我不知道为什么它显示我此错误
公告:未定义的索引:文件C:\ XAMPP \ htdocs中\项目\ upload.p惠普在第6行任何帮助将提前感激!
HTML代码<形式行动= “upload.php的” 方法= “POST” ENCTYPE = “多部分/格式数据”> <标签类=“定做文件输入“for =”文件“> – Hafsa
由于您在'$ _FILES'中可用之前访问'file' – JYoThI
** 1st:**因为在它可用之前访问'file'在'$ _FILES'中。 **第二:**将您的代码移入'isset()'中。 **第三:**您需要添加提交输入。 '' – JYoThI