WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Using PHP im HTML image tags
Categories : PHP, HTML and PHP, Graphics, Beginner Guides Click here to Update Your Picture
John Risken
Date : Sep 11th 2008
Grade : 1 of 5 (graded 3 times)
Viewed : 3009
File : No file for this code example.
Images : No Images for this code example.
Search : More code by John Risken
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

A simple example that allows images to be included in HTML without being in the web site's file path

I’ve looked in a pot-full of forums for the answer to this question:
How can I get the ‘src’ parameter of an HTML ‘img’ tag to refer to an image that is not in the web site’s path? I wanted to be able to do this so that images could be more secure and wouldn’t need to be replicated for multiple subdomains.

What I finally pieced together is very straightforward: the seeds of it were in several places, but here’s a working model all in one place.
(By the way, this has been tested with Fireefox, IE7, and Chrome. My web site runs under PHP 5 on an Apache server.)

I decided to keep my images in a folder called ‘help’ that is at a peer level with ‘public_html’. In ‘help’ I have another folder called ‘sample’

Here’s the original image tag: <img src=”sample/myPicutre.jpg”>

Here’s the modified tag: <img src=”index.php?helpimage=sample/myPicture.jpg">

Here’s how my modified index.php file looks

index.php
<?php
extract
($_GET); // will contain the ‘helpimage’ variable
if(isset($helpimage)) // if this is a call for an image
{
   
$f=pathinfo($helpimage); // and if its an actual image file (hacker-resistance)
   
if($f['extension']=="jpg")
    {
       
chdir("../help"); // jump up  one level to the help folder
       
readfile($helpimage); // and send the image back to the browser.
       
return; // that’s it
   
}
}
?>


… whatever else index.php is supposed to do



How to preset a text string in a textarea input field
Categories : HTML, HTML and PHP, PHP, Beginner Guides
Newbie Notes #1 - Making a form return to itself
Categories : PHP, Beginner Guides, HTML and PHP
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
Simple POST and GET example
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
Snipe.Net's Web Design Color Scheme Previewer- Allows uses to input hex codes for their text, background, and link colors, and preview the color scheme with their background image. Example: http://www.snipe.net/tech/snipeschool/hex.php3
Categories : PHP, HTML and PHP, General, Graphics, HTML
Barcodes On The Fly With GD
Categories : Ecommerce, Graphics, HTML and PHP, PHP
PHP based HTML rabbing Tools
Categories : PHP, HTML and PHP, Tag Extractors, Regexps, Beginner Guides
Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
How to Create a Shoutbox Using PHP & MySQL
Categories : PHP, MySQL, Web Applications, Beginner Guides, HTML and PHP
Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
Functions for loading images into a MySQL database and displaying them.
Categories : Graphics, HTML and PHP, MySQL, PHP, Databases
How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics