我很难使用HTML文件输入。每次我vardump $ _FILES数组我都可以看到它是完全空的:array(0) { }
以及以下注意事项:
Notice: Undefined index: upload in C:\xampp\htdocs\pages\addproperty.sfwp on line 29
Notice: Undefined index: upload in C:\xampp\htdocs\pages\addproperty.sfwp on line 31
Notice: Undefined index: upload in C:\xampp\htdocs\pages\addproperty.sfwp on line 36`
有人可以查看我的代码吗?
HTML:
<input type="file" class="form-control" placeholder="Afbeelding" name="upload">
PHP:
$insert = $Properties->createProperty($catid,$typeid, $title, $price, $adressline1, $adressline2, $postalcode, $city, $province, $country, $sellerid, $avbedrooms, $avbathrooms, $avparkingspots, $claimsize, $livesize, $details);
if($insert){
echo $insert;
var_dump($_FILES);
$uploaddir = 'usrContent/';
$uploadfile = $uploaddir . "IMG_".$insert."_01.".end((explode(".", $_FILES['upload']['name'])));
$ext = end((explode(".", $_FILES['upload']['name'])));
if($ext != "png" || $ext != "jpeg" || $ext != "jpg"){
}
if (move_uploaded_file($_FILES['upload']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload went Wrong!\n";
}
}else{
echo"2";
}
答案 0 :(得分:4)
请在表单中添加enctype="multipart/form-data"
..