php读取数组表单上传文件

时间:2011-10-06 13:45:35

标签: php html forms

<form name="classupload" method="post"  enctype="multipart/form-data" action="">
      <h3>Select pictures:&nbsp;</h3><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />

      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
       <div id="viac"></div>
         <div style="margin-top:4px;"><a onclick="multiupload();">More</a><br /></div>
        <input type="submit" value="Upload" id="classupload"/>
      </form>

如何使用php lang阅读此表单, 非常感谢

1 个答案:

答案 0 :(得分:0)

$destDir = '/mydir/'; // Where we will put the files

for ($i = 0; $i < 5; $i++) {
  if (!$_FILES['Filedata']['error'][$i]) { // only process files that are present and were uploaded successfully
    move_uploaded_file($_FILES['Filedata']['tmp_name'][$i],$destDir.$_FILES['Filedata']['tmp_name'][$i]);
  }
}

这些文件现在位于$destDir