我有简单的代码在我的服务器上上传多张照片.. Evrything工作正常,但我需要在MySql中使用p,2.,2.png,3.png
请求帮助..我还在学习..
form.html
<form action="upload.php" method="post" enctype="multipart/form-data">
<p><input type="file" name="img[]"></p>
<p><input type="file" name="img[]"></p>
<p><input type="file" name="img[]"></p>
<input type="submit" value="Upload all files">
</form>
upload.php的
<?php
if(isset($_FILES['img'])){
$name_array = $_FILES['img']['name'];
$tmp_name_array = $_FILES['img']['tmp_name'];
$type_array = $_FILES['img']['type'];
$size_array = $_FILES['img']['size'];
$error_array = $_FILES['img']['error'];
for($i = 0; $i < count($tmp_name_array); $i++){
if(move_uploaded_file($tmp_name_array[$i], "pics/".$name_array[$i])){
echo $name_array[$i]." upload is complete<br>";
} else {
echo "move_uploaded_file function failed for ".$name_array[$i]."<br>";
}
}
}
?>
答案 0 :(得分:0)
试试这个upload.php:
pane__title
答案 1 :(得分:0)
请将文件名保存在循环中,如下所示
$file = rand(1000,100000)."-".$_FILES['file']['name'];
然后在上传后插入
$sql="INSERT INTO tbl_uploads(file,type,size) VALUES('$file','$file_type','$file_size')";
mysql_query($sql);