Jump to content

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();
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.