PHP文件上传脚本不上传文件

时间:2015-11-11 10:43:04

标签: php file-upload

我有这个代码来上传多个文件。

我可以浏览和选择文件,但无法上传到指定的文件夹。

<span class="btn btn-primary btn-file">
          Browse <input name="upload[]" type="file" multiple="multiple" />
</span>

    <!-- processing the selected files -->

<?php
for($i=0; $i<count($_FILES['upload']['name']); $i++) {

//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];    

if ($tmpFilePath != ""){
  //Setup our new file path
  $newFilePath = "./uploadedFiles/" . $_FILES['upload']['name'][$i];

  //move to new path
  move_uploaded_file($tmpFilePath, $newFilePath) ;
}
}
?>

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

您可能错过

上的 enctype
<form method="post" enctype="multipart/form-data">

因为大多数人都忘了它。

相关问题