User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 330,317 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,830 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
6 Days Ago
Views: 147
This code will display images within an email from the server. It will display an image with a choice of file extension which can be expanded to fit your needs.

this code was originally developed for a emailing system where the images to be displayed where uploaded by the user.
php Syntax
  1. $image = "";
  2. $broad_img1= "";
  3. //this has to be set like this as if file exist does not work with absolute paths
  4. $path= 'http://wwwyour web site.com';
  5. //this is the directory where the images are stored
  6. $web_image_folder = 'image/thumbs';
  7. $exts = array('jpg', 'png', 'gif', 'jpeg');
  8. //the name of the file on the server
  9. $image_name = 'thumb_image1';
  10.  
  11.  
  12. // check for each extension
  13. foreach($exts as $ext) {
  14. if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext)) {
  15. $image = $image_name.'.'.$ext;
  16. }
  17. }
  18.  
  19. // check if we have an image
  20. if ($image != "") {
  21. // ok we have the image now store it in a variable
  22. $broad_img1='<img src="' . $path."/".$web_image_folder."/".$image . '" />';
  23. } else {
  24. // error, we can't find the image.
  25. }
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 7:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC