[英]cant upload an image file
我有这个:
<input type="file" name="image">
if(isset($_POST['submit']))
{
if(isset($_FILES['image']['name']))
{
$image=$_FILES['image']['name'];
}
else
{
$error= 'Error: no image was set ';
}
基本上,它告诉我图像,名称不存在不存在..为什么?
{
$error= 'Error: no image was set ';
}
您的FORM是否具有enctype =“ multipart / form-data”属性?
<form name="xyz" action="myscript.php" enctype="multipart/form-data">
...
</form>
EncType属性用于告诉浏览器如何将数据发布到服务器。 如果您不使用多部分mime类型,则无法将数据正确发送到服务器。
多部分看起来像这样:
boundary:xyz
====xyz====
name: field1
content-type: text/plain
content-lenght: 10
1234567890
====xyz====
name: field2
content-type: text/plain
content-lenght: 10
1234567890
====xyz====
name: field3
content-type: text/plain
content-lenght: 10
1234567890
您不必自己发送它,只需设置enctype,一切为您完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.