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));