php - headers to force the download of a tar archive -
I have a tar archive on the server that must be downloaded via php. This is the code I used:
$ content = file_get_contents ($ tar); Header ("content-type: application / force-download"); Header ("content-dispute: attachment; file name = $ tar"); Header ("content-length:". Refrain ($ content)); Unlink to ($ name); Die ($ content);
The file has been downloaded, but it is broken and can not open it. I think there is something wrong with the header because the files on the server may be open without problems. Do you know how I can solve this problem?
UPDATE I have tried to print an iframe like this:
& lt; Iframe src = "& lt ;? php echo $ tar? & Gt;" & Gt; & Lt; / Iframe & gt;
And the download works, so I'm sure something missing in the header.
I used this code when I had to:
Download the function _D ($ f_location, $ f_name) {header ('content-description: file transfer'); Header ('content-type: application / octet-stream'); Header ('content-length:' filesystem ($ f_location)); Header ('content-dispute: attachment; file name =' .busname ($ f_name)); Readfile ($ f_location); } Download ("../directory/to/TR/Raj.", "Secrets."); // or download ("/ var / www / vhost / domain.com / httpdocs / directory / to / tar / raj.tar", "raj.tar"); Try
Comments
Post a Comment