当我运行以下代码时,它说
"注意:未定义的索引:c: xampp htdocs imagetest processimage.php in 17"
但是,当我用filetoupload替换每个实例时,它似乎有效。为什么?
processimage.php
<!DOCTYPE html>
<html>
<head>
<title> hello world</title>
</head
<body>
<?php
echo ' hi';
$servername="localhost";
$username="root";
$password="";
$dbname="db_ImageTest";
$conn=new mysqli($servername, $username, $password, $dbname);
echo $_FILES["uploadFile"]["name"];
/*
echo $image;
$image_name=$_FILES['image']['name'];
$image_size=getimagesize($_FILES['image']['tmp_name']);
if($image_size==FALSE){
echo 'failed';
}
$query="INSERT INTO mytable(image, name) VALUES(' {$image}', '{$image_name}')
*/
?>
</body>
</html>
index.php
<!DOCTYPE html>
<html>
<body>
<form action="processImage.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="uploadFile" />
<input type="submit" value="Upload Image" name="submit"/>
</form>
</body>
</html>
"注意:c: xampp htdocs imagetest takentest processimage.php in Line 17"
这意味着未发送文件,您可以使用 isset
检查是否附加了文件,否则会发出通知:
if (isset($_FILES['uploadFile'])) {
/** file is there, continue your uploading **/
}