我想用表单提交一张图片,用img标签表示的一张.不是用file类型的input标签选择的那种,可以吗?
下面是html和php部分代码:
HTML:
<form action="demo.php" method="post"enctype="multipart/form-data">
<table width="50%" border="1" cellspacing=0 cellpadding=5>
<tr bgcolor="#F2F2F2">
<td class="tableheader" align="left">
 图片区域 
</td>
</tr>
<tr>
<td align="left" height="105" ondragenter="return false" ondragover="return false" ondrop="dropIt(event)">    
<output id="thumbs"><img name="id1" src="pic/ah.jpg"/></output> 
</td>
</tr>
<tr>
<td align="center">
 
<input type="file" id="input" size="10" multiple="true" onchange="imagesSelected(this.files)" />
<input type="submit" name="submit1" value="上传" />
 
</td>
</tr>
</table>
</form>
PHP:
<?php
$imga = $_FILES ["id1"];
  echo "Invalid file";
?>

解决方案 »

  1.   

    为什么?
    我用<input type="image" 也不行啊
      

  2.   

    $_FILES 只针对 <input type="file"  >控件才存在 
      

  3.   


    +1form也要设置搵encryption什么什么的。
      

  4.   

    那用什么?用$_POST?还是没有了别的方法.
      

  5.   

    如果只限定表单提交就只有 <input type="file"  /> + post方式
      

  6.   

    用表单上传文件,必须是:
    表单必须有
    method="post"
    enctype="multipart/form-data"
    属性
    通过 input type=file 控件上传 这是规定,没有“为什么”
      

  7.   

    手册上是这么说的:例子 18-1. 文件上传表单<form enctype="multipart/form-data" action="_URL_" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="30000">
    Send this file: <input name="userfile" type="file">
    <input type="submit" value="Send File">
    </form>
     
     以上范例中的“_URL_”应该替换成指向一个 PHP 文件的真实 URL。MAX_FILE_SIZE 隐藏域(单位为字节)必须先于文件输入域,其值为接收文件的最大尺寸。同时,要保证您的文件上传表单中要有 enctype="multipart/form-data",否则文件上传将不能工作。