jakebur01 Posted November 8, 2019 Share Posted November 8, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309484-imagejpeg-give-browser-a-file-name/ Share on other sites More sharing options...
chhorn Posted November 8, 2019 Share Posted November 8, 2019 (edited) Just use that .jpg name within the URL and redirect to a .php script with mod_rewrite. Edited November 8, 2019 by chhorn Quote Link to comment https://forums.phpfreaks.com/topic/309484-imagejpeg-give-browser-a-file-name/#findComment-1571339 Share on other sites More sharing options...
requinix Posted November 8, 2019 Share Posted November 8, 2019 header('Content-Disposition: inline; filename="imagename.jpg"'); Quote Link to comment https://forums.phpfreaks.com/topic/309484-imagejpeg-give-browser-a-file-name/#findComment-1571346 Share on other sites More sharing options...
Barand Posted November 8, 2019 Share Posted November 8, 2019 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? Quote Link to comment https://forums.phpfreaks.com/topic/309484-imagejpeg-give-browser-a-file-name/#findComment-1571350 Share on other sites More sharing options...
jakebur01 Posted November 8, 2019 Author Share Posted November 8, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309484-imagejpeg-give-browser-a-file-name/#findComment-1571353 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.