turkman Posted September 4, 2010 Share Posted September 4, 2010 i have an image uploader... that people can link directly to an image. But say for example that image gets deleted. When someone tries to link to it i want it to display a custom imagedeleted.jpg how can i do this? Link to comment https://forums.phpfreaks.com/topic/212509-need-help-displaying-imagedeletedjpg-when-i-delete-an-image/ Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Share Posted September 4, 2010 This would probably be better handled with some directives in an .htaccess file unless you're using the image file name as a get request, but I doubt that. Or, if you're using lighty, you would need a rewrite entry in your conf file. Link to comment https://forums.phpfreaks.com/topic/212509-need-help-displaying-imagedeletedjpg-when-i-delete-an-image/#findComment-1107156 Share on other sites More sharing options...
MasterACE14 Posted September 4, 2010 Share Posted September 4, 2010 if(!file_exists($imagepath)) { echo "<img src='imagedeleted.jpg' />"; } something like that? Link to comment https://forums.phpfreaks.com/topic/212509-need-help-displaying-imagedeletedjpg-when-i-delete-an-image/#findComment-1107159 Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Share Posted September 4, 2010 No, he's talking about accessing the file directly and displaying an imagedeleted.jpg if it's been deleted. In your image directory, where the actual images are stored, create an .htaccess file and put something like this in it: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ RewriteRule .* path/to/imagedeleted.jpg [L] If you're running your own VPS make sure you enable the mod_rewrite, or it probably is enabled by default anyways. Make sure the path to imagedeleted is in a web accessible folder. Link to comment https://forums.phpfreaks.com/topic/212509-need-help-displaying-imagedeletedjpg-when-i-delete-an-image/#findComment-1107160 Share on other sites More sharing options...
turkman Posted September 8, 2010 Author Share Posted September 8, 2010 i have htaccess working in other parts of the site but the code posted above does not work, when i click on an invalid link it just says oops this link appears to be broken. Obviously i have changed the path to image bit. Anyone any ideas? Link to comment https://forums.phpfreaks.com/topic/212509-need-help-displaying-imagedeletedjpg-when-i-delete-an-image/#findComment-1108700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.