sroberge Posted August 11, 2009 Share Posted August 11, 2009 I've been avoiding asking for days figuring that there is something that I am missing. I can't seem to figure this one out. I have tried everything that I can think of or find. Can someone please help? Below is an outline of the code: This page is the actual form that the email recipient goes to, to select the pictures that they would like to download. The ‘%PICS%’ variable is replaced with the image path to the images in the users directory also creating a checkbox for the user to select the image. <form method="post" action="index.php?action=download"> %PICS% <input type="submit" name="submit" value="Download"> </form> So far, simple enough. On submit this page submits back to itself and falls into this chuck of code: require('../../uploader/force-download.php'); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if ($action == 'download') { $count = count($_POST['pic']); for($i = 0; $i < $count; $i++) { $filename[] = $_POST['pic'][$i]; } download($filename); This part of the code places all the user selected images into an array $filename then passes it to the function download located in force-download.php. Again, simple enough. Force-download.php: function download($array) { for($i = 0; $i < count($array); $i++) { $filename = $array[$i]; if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); $file_extension = strtolower(substr(strrchr($filename,"."),1)); switch( $file_extension ) { case "pdf": $ctype="application/pdf"; break; case "zip": $ctype="application/zip"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Description: File Transfer'); header("Cache-Control: private",false header("Content-Type: $ctype"); header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" ); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($filename)); ob_clean(); flush(); readfile($filename); } } I can only get the first picture to download and not the rest. Any help would be greatly appreciated!!! Link to comment https://forums.phpfreaks.com/topic/169791-readfile-multiple-picture-download/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.