php添加多个上传表单

php添加多个上传表单,php,Php,我有一张上传照片的表格。我知道如何允许多个文件,但我不知道如何编辑php以允许发送多个图片。任何帮助都将不胜感激。谢谢 您不需要设置任何东西来允许在php中上载多张图片 但你必须注意: 将其添加到htaccess文件: <IfModule mod_php5.c> php_value post_max_size 200M php_value upload_max_filesize 200M php_value memory_limit 300M php_val

我有一张上传照片的表格。我知道如何允许多个文件,但我不知道如何编辑php以允许发送多个图片。任何帮助都将不胜感激。谢谢


您不需要设置任何东西来允许在php中上载多张图片

但你必须注意:

将其添加到htaccess文件:

<IfModule mod_php5.c>
   php_value post_max_size 200M
   php_value upload_max_filesize 200M
   php_value memory_limit 300M
   php_value max_execution_time 259200
   php_value max_input_time 259200
   php_value session.gc_maxlifetime 1200
</IfModule>

php_值后最大尺寸200M
php\u值上传\u最大\u文件大小为200M
php\u值内存\u限制300M
php_值最大执行时间259200
php_值最大输入时间259200
php_value session.gc_maxlifetime 1200

HTML:


PHP:

/$files=array_filter($_files['upload']['name'])//在处理文件之前要使用类似的东西。
//阵列中上载文件的计数#
$total=计数($_文件['upload']['name']);
//循环浏览每个文件
对于($i=0;$i<$total;$i++){
//获取临时文件路径
$tmpFilePath=$\u文件['upload']['tmp\u name'][$i];
//确保我们有一个文件路径
如果($tmpFilePath!=“”){
//设置我们的新文件路径
$newFilePath=“./uploadFiles/”$_FILES['upload']['name'][$i];
//将文件上载到临时目录
if(移动上传的文件($tmpFilePath,$newFilePath)){
//在这里处理其他代码
}
}
}

希望这有帮助

这很管用,但是图片的名称会被发送到我的电子邮件中,但按照我的方式,它只会在我的电子邮件中发送一个图片id。我怎样才能把它全部改成它们呢。谢谢


<input name="upload[]" type="file" multiple="multiple" />
//$files = array_filter($_FILES['upload']['name']); //something like that to be used before processing files.

// Count # of uploaded files in array
$total = count($_FILES['upload']['name']);

// Loop through each file
for( $i=0 ; $i < $total ; $i++ ) {

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

  //Make sure we have a file path
  if ($tmpFilePath != ""){
    //Setup our new file path
    $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];

    //Upload the file into the temp dir
    if(move_uploaded_file($tmpFilePath, $newFilePath)) {

      //Handle other code here

    }
  }
}