Issue
So I have written a GD image 'modifier' we'll call it, and using the imagejpeg function, I output it to the browser. I'm curious if there is perhaps header information that I can pass that will instruct the browser to download the file with a name other than that of the PHP file that is handing the data back.
The scenario is that my PHP file, 'generate.php' for now, hands an image header out and outputs the image, but if I go to save the image, the default filename is 'generate.php'. I'd like to hand back a dynamically generated filename instead.
If code is a must here for some reason; I'll be glad to post it - but I feel it's not necessary in this case.
Solution
Send a Content-Disposition
header.
To display the image:
header("Content-Disposition: Inline; filename=$filename");
To download the image:
header("Content-Disposition: Attachment; filename=$filename");
Answered By - AbraCadaver Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.