hlstriker Posted March 14, 2009 Share Posted March 14, 2009 I am creating images via GD perfectly but there is only one problem. When I right click the image and click "Save image as...", the filename will be 'image.php.jpeg'. Is there a way I can make this display as only 'image.jpeg'? Quote Link to comment https://forums.phpfreaks.com/topic/149347-gd-help-when-saving-file/ Share on other sites More sharing options...
Festy Posted March 14, 2009 Share Posted March 14, 2009 I am creating images via GD perfectly but there is only one problem. When I right click the image and click "Save image as...", the filename will be 'image.php.jpeg'. Is there a way I can make this display as only 'image.jpeg'? I'm not sure but there must be a GD library function, which allows us to set the name of the image. Quote Link to comment https://forums.phpfreaks.com/topic/149347-gd-help-when-saving-file/#findComment-784374 Share on other sites More sharing options...
.josh Posted March 14, 2009 Share Posted March 14, 2009 when I "Save as.." the filename is in an editable text field, and I can change it. As in, remove the current extension, so it only saves as blah.jpg. If for some reason you can't do that, you can rename it after the file is saved, by rightclick > rename or rightclick > properties (windows). Quote Link to comment https://forums.phpfreaks.com/topic/149347-gd-help-when-saving-file/#findComment-784411 Share on other sites More sharing options...
.josh Posted March 14, 2009 Share Posted March 14, 2009 Alternatively...since the issue is that the image is really a php file generating an image and sending it as a raw image to the browser, you could have your script save the file on the server as blah.jpg instead of outputting it, and then have the script redirect to the saved image. Quote Link to comment https://forums.phpfreaks.com/topic/149347-gd-help-when-saving-file/#findComment-784414 Share on other sites More sharing options...
rjcb23 Posted October 23, 2012 Share Posted October 23, 2012 Late to reply to this but thought it may serve as useful for anyone hitting on this as I did from Google. A quick and easy way to force the browser to allow you to save as a particular filename and/or extension is to pass the filename and extension into the URL (or form action depending on how you are generating the image) eg as a form post <form name="myform" action="picgenerator.php?name=thepic.jpg" method="post">... or as just a URL (in the querystring) http://www.mywebsite.com/picgenerator.php?name=thepic.jpg Now, right-clicking on the image and choosing "Save as" (or equivalent, depending on which browser you are using) will save the file as a jpeg defaulting to the name thepic.jpg Works for all browsers (as far as I know) Quote Link to comment https://forums.phpfreaks.com/topic/149347-gd-help-when-saving-file/#findComment-1387340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.