Jump to content

Download all checked files dynamically


anolan13

Recommended Posts

Hello,

 

Once again I need some help with more advanced check boxes. Right now I have it so that files are displayed from a folder and next to them there is a check box, and at the bottom a delete button. If you check the boxes it deletes the selected file.

 

Now what if I need a second button that when checked and clicked downloads the selected file to the users computer? This possible with PHP? I don't know if it is because of security issues maybe? Any help please?

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/65148-download-all-checked-files-dynamically/
Share on other sites

would be better to create a zip with the selected files and download that, well thats what i did..

 

heres my old forceDownload funtion

<?php
function forceDownload($archiveName) {
$headerInfo = '';

if(ini_get('zlib.output_compression')) {
	ini_set('zlib.output_compression', 'Off');
}

// Security checks
if( $archiveName == "" ) {
	echo "<html><title>Download </title><body><BR><B>ERROR:</B> The download file was NOT SPECIFIED.</body></html>";
	exit;
} 
elseif ( ! file_exists( $archiveName ) ) {
	echo "<html><title>Download </title><body><BR><B>ERROR:</B> File not found.</body></html>";
	exit;
}

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/zip"); //<--- NOTICE I USED ZIP
header("Content-Disposition: attachment; filename=".basename($archiveName).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($archiveName));
readfile("$archiveName");
exit();
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.