Wednesday, October 17, 2018
Downloading file using PHP pointer
Answer
I am storing files above the root directory of my server, and I'm planning on giving users a download by using a php file.
Here is my code:
For the download link:
Download
and for the FileGrab.php file:
//This will grab a file from the server
if (file_exists(UPLOAD_ADR.$_GET['adr'])) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.CATPart"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header("Content-length: ".filesize(UPLOAD_ADR.$_GET['adr']));
readfile(UPLOAD_ADR.$_GET['adr']);
exit;
}
?>
I got the above code (in essence) from here
FileGrab.php is loading but it looks like it is just spewing out a raw text form of the file, arbitrary text/symbols etc.
Checked that the file exists, and file size returns a value. Don't know how to get anymore errors to check out of it!
Does it make a difference this is a .CATPart file, which is a little abstract but necessary...
Any help greatly appreciated :)
Subscribe to:
Post Comments (Atom)
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
i've started to create my website, but now i have few doubts. I've searched, that MySqli object oriented is good to use beca...
-
I've been asked to update some Excel 2003 macros, but the VBA projects are password protected, and it seems there's a lack of docume...
No comments:
Post a Comment