[英]Undefined index: image in C:\wamp\www\netupdate.php on line 21
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. 现在,怪异的部分是除图像以外的其他所有参数都在php脚本中被接受,我正在将所有内容写入数据库,并给出了成功消息,但是只有这一部分给出了错误,甚至更怪异的部分是类似的脚本在其他mysql表中运行良好,所以我猜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">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.