PHP获得多个上传的文件名 [英] PHP get names of multiple uploaded files

查看:125
本文介绍了PHP获得多个上传的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨即时试图创建一个脚本来上传多个文件。
万物工作至今,所有文件被上传。

Hi im trying to create a script to upload multiple files. everythings works so far and all files are being uploaded.

我现在的问题是,我需要虎视眈眈上传文件中的每个文件名,这样我就可以在一个DATEBASE插入。

My problem now is that i need to grap each file name of the uploaded files, so i can insert them in to a datebase.

下面是我的html:

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

  <input type="file" name="image[]" multiple />
  <input type="submit" value="upload" />

这是PHP的:

if (!empty($_FILES['image'])) { 
    $files = $_FILES['image'];

    for($x = 0; $x < count($files['name']); $x++) {
        $name       = $files['name'][$x];
        $tmp_name   = $files['tmp_name'][$x]; 
        $size       = $files['size'][$x]; 

        if (move_uploaded_file($tmp_name, "../folder/" .$name)) {
            echo $name, ' <progress id="bar" value="100" max="100"> </progress> done <br />';
        }
    }
}

真希望有人能帮助我与此有关。
/ JL

Really hope someone can help me with this. /JL

推荐答案

感谢您的帮助,我得到它通过简单地创建变量工作:

Thanks for the help, i got it to work by simply creating variables:

$image_1 = (print_r($files['name'][0], true)); 
$image_2 = (print_r($files['name'][1], true)); 
$image_3 = (print_r($files['name'][2], true)); 

这篇关于PHP获得多个上传的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆