I am facing some weird problem. Here is my file upload snipped of the form through which I am trying to upload the image to my server
<input type="file" name="image" id="image">
And I am getting the error:
Undefined index: image in C:\wamp\www\netupdate.php on line 21
My upload script is as following
// file upload scrpt
$name= $_FILES['image']['name'];
$tmp_name = $_FILES['image']['tmp_name'];
$type = $_FILES['image']['type'];
$size = $_FILES['image']['size'];
$pathAndName = "file:///c:/wamp/www/upload/networking/".$name;
$moveResult = move_uploaded_file($tmp_name, $pathAndName);
Now the weird portion is that all other parameters are being accepted in the php script other than the image, I am writing everything to my database and its giving a success message but only this portion is giving errors and even weirder part is that a similar script is working perfectly in other mysql table so I guess there is nothing wrong in php_ini.
您可能在<form>
元素上缺少enctype="multipart/form-data"
。
<form action="netupdate.php" method="post" enctype="multipart/form-data">
确保您的表单标签上有enctype="multipart/form-data"
<form id="xx" name="xxx" action="xxx.php" method="post" enctype="multipart/form-data">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.