Php multi-file upload/download sample code
Php multi-file upload/download sample code
index_uploads
Index_uploads.php
"; print_r($_FILES); echo "
"; $ Count = count ($ _ FILES ['file'] ['name']); for ($ I = 0; $ I <$ count; $ I ++) {$ tmpfile = $ _ FILES ['file'] ['tmp _ name'] [$ I]; $ filefix = array_pop (explode (". ", $ _ FILES ['file'] ['name'] [$ I]); $ dstfile =" uploads/files /". time (). "_". mt_rand (). ". ". $ filefix; if (move_uploaded_file ($ tmpfile, $ dstfile) {echo "script" alert ('succeed! '); Window. location. href = 'listdir. php'; script ";} else {echo" script "alert ('Fail! '); Window. location. href = 'index _ uploads. php'; script ";}
Uploads. php
"; Echo""; Echo"Download"; Echo"";}}} Echo" image download | image upload "; echo"
"; Listdir ($ dirname); echo"
";
Listdir. php
Download. php
Core download:
header("content-type:application/octet-stream");header("content-disposition:attachment;filename={$imgfile}");header("content-length:{$imgsize}");readfile($path);