This article illustrates a simple way to upload a picture in bulk in PHP. Share to everyone for your reference, specific as follows:
<?php function Upload_multi ($path, $photo, $i) {$uploaddir = './'. $path//File storage directory if (!file_exists ($uploaddir))//
If the directory does not exist, create a new $uploaddir =mkdir ($uploaddir);
$piece = Explode ('. ', $photo [' name '] [$i]); $uploadfile = $uploaddir. '/'. MD5 ($piece [0]).
$piece [1];
$result = Move_uploaded_file ($photo [' tmp_name '] [$i], $uploadfile);
if (! $result) {exit (' upload failed ');} return basename ($uploadfile); } if ($_post[' Tijiao ']) {extract ($_post); $i =0; foreach ($_files["Pictures"] ["error"] as $key => $error) {if ($error = =
UPLOAD_ERR_OK) {Upload_multi ($email, $_files["Pictures"], $i);} $i + +; }?> <script language= "JavaScript" > Function go_up () {document.getElementById (' new_up '). innerhtml+= ' <
Input type= "file" name= "pictures[" "/><br>"; } </script> <form action= "index.php" method= "post" enctype= "Multipart/form-data" > <p> multi-picture upload </p ><br> <input type= "file" Name= "pictures[]"/><br> <div id= "new_up" ></div> <input Type= "button" "Name=" adD_img "value=" New Upload "onclick=" go_up () "/><br> <input type=" Submit "value=" Send "name=" Tijiao "/><br
> </form>
More interested in PHP related content readers can view the site topics: "PHP file Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "Basic PHP Grammar Introduction Tutorial", "PHP operation Office Document skills Summary (including Word, Excel,access,ppt), "The PHP date and time usage summary", "PHP object-oriented Programming Introduction Tutorial", "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation skill Summary"
I hope this article will help you with the PHP program design.