How can I use jQuery Checkboxs to select and then open and/or print documents stored in a content system (html link to get .pdf doc) -
I am a Noah to do all this and are stuck!
I have a table which is something like this:
& lt; Tr class = "req" & gt; & Lt; Td> & Lt; Input name = "checkbox" type = "checkbox" id = "Pform70" /> & Lt; / Td> & Lt; Td align = "left" & gt; & Lt; A href = "https://www.yadayada.com/uat088922.pdf" heading = "form title" id = "Pform70" target = new & gt; Pform70 & lt; / A & gt; & Lt; / TD & gt; & Lt; TD & gt; Required & lt; / TD & gt; & Lt; Td> Form Title & lt; / Td> & Lt; TD & gt; Ksdjasdjf; Alsdjfal; & Lt; / TD & gt; So- I have to put a button above the table, when clicked, either open all the checked documents or print out the checked documents.
I am searching, coming near, but not enough, thank you all!
You can download selected (checked) items in a composite .zip file.
First of all, create a form containing your files:
& lt; Form action = "download.php" method = "get" & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input type = "submit" name = "mysubmit" value = "download!" & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "req" & gt; & Lt; Td> & Lt; Input type = "checkbox" name = "file [0]" id = "Pform70" /> gt; & Lt; / Td> & Lt; Td align = "left" & gt; & Lt; A href = "https://www.yadayada.com/uat088922.pdf" heading = "form title" id = "Pform70" target = new & gt; Pform70 & lt; / A & gt; & Lt; / TD & gt; & Lt; TD & gt; Required & lt; / TD & gt; & Lt; Td> Form Title & lt; / Td> & Lt; TD & gt; Ksdjasdjf; Alsdjfal; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; The name of the check box is array!
Here's the download. Php:
if (empty ($ _POST ['file'])) {// open zip $ zip_path = '/path/to/created/download.zip'; $ Zip = new zip archive (); If ($ zip-> open ($ zip_path, ZIPARCHIVE :: CREATE)! == TRUE) {Dead ("Error creating your zip file."); } // checkbox value no matter because the check box is shown as POST data foreach ($ _POST ['file'] $ key = & gt; $ val) {// $ filename = '/ path / For / php / file '$ key' .php '; $ Zip- & gt; Adfile ($ filename) or die ("Error: file $ filename could not be added"); } $ Zip- & gt; Close (); // =============== Download force // ================ Assume that you have complete access to these Path is $ Zip_path if (! Is_file ($ zip_path)) {dead ('file appears invalid.'); } $ Zip_path = str_replace ('\\', '/', actual path ($ zip_path)); $ Filesize = filesize ($ zip_path); $ Filename = substr (strrchr ('/'. Zip_path, '/'), 1); $ Extension = stroller (substring (str ($ zip_path, '.'), 1)); // Unless you want to find the mime type based on the extension $ mime = array ('application / octet-stream'), use it; Header ('content-type:'. $ Mime); Header ('content-dispute: attachment; filename =' '. $ Filename.' '' ''); Header ('content-transfer-encoding: binary'); Header ('content-length:' .sprintf ('% d', $ filesize)); Header ('expiration: 0'); // IE check for header only if isset ($ _ server ['HTTP_USER_AGENT']) & (strops ($ _ server ['HTTP_USER_AGENT'], 'MSIE')! == incorrect)) {header ('Cash - Control: Required-Modified, Post Check = 0, Pre-Check = 0'); Header ('pragma: public'); } Other {Header ('Predama: No-Cash'); } $ Handle = fopen ($ filepath, 'rb'); Fpassthru ($ handle); Fclose ($ handle); } // close $ _POST check You can read more in php.net docs.
Comments
Post a Comment