Jump to content
jakebur01

imagejpeg( ) give browser a file name

Recommended Posts

Is it possible to feed the browser a default save as name for the image when outputting to the browser, instead of it defaulting to the .php file name?

So, instead of myimage.php I could use imagename.jpg or whatever I want.

Share this post


Link to post
Share on other sites

Just use that .jpg name within the URL and redirect to a .php script with mod_rewrite.

Edited by chhorn

Share this post


Link to post
Share on other sites
header('Content-Disposition: inline; filename="imagename.jpg"');

 

Share this post


Link to post
Share on other sites
9 hours ago, jakebur01 said:

when outputting to the browser,

Why would it need a default name to output the image in the browser? 

Or are you wanting the user to download the image?

Share this post


Link to post
Share on other sites
1 hour ago, requinix said:

header('Content-Disposition: inline; filename="imagename.jpg"');

 

That's exactly what I was looking for!! Thank you.  That is awesome.

@Barand Yes, for users to download.  It's a lot cleaner to me than a php file name.  And I'm using a variable as the filename.

Share this post


Link to post
Share on other sites

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.