学堂 学堂 学堂公众号手机端

一个简单的php批量上传程序

lewis 1年前 (2024-04-16) 阅读数 15 #技术
<html>


<head>


<title>


upload picture more once


</title>


</head>


<body>


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


<p>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="上传" />

</p>



</form>



</body>



</html>


<?php if($_POST['upload'])


{ $dest_folder

=
"picture/";



if(!file_exists($dest_folder))



{
mkdir($dest_folder);

}



print_r($_FILES["pictures"]["error"]);





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;


move_uploaded_file($tmp_name, $uploadfile);


}







}






}


?>

版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门