怎么在PHP项目中批量上传图片

怎么在PHP项目中批量上传图片?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

代码如下:


<
html
>

<
head
>
<
title
>
uploadpicturemoreonce
</
title
>
</
head
>

<
body
>

<
form

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

<

>
Pictures:
<
br

/>

<
input

type=
"file"
name=
"pictures[]"
/>
<
br

/>

<
input

type=
"file"
name=
"pictures[]"
/>
<
br

/>

<
input

type=
"file"
name=
"pictures[]"
/>
<
br

/>

<
input

type=
"submit"
name=
"upload"
value=
"Send"
/>

</

>

</
form
>

</
body
>

</
html
>

<?
php

if($_POST['upload']=='Send'){

$dest_folder=
"picture/";18.if(!file_exists($dest_folder)){19.mkdir($dest_folder);

}

foreach($_FILES["pictures"]["error"]as$
key=
>
$error){

if($
error==UPLOAD_ERR_OK){

$tmp_name=$_FILES["pictures"]["tmp_name"][$key];

$name=$_FILES["pictures"]["name"][$key];

$uploadfile=$dest_folder.$name;26.move_uploaded_file($tmp_name,$uploadfile);

}
}
}
?>

关于怎么在PHP项目中批量上传图片问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。