The Little Guy Posted September 8, 2008 Share Posted September 8, 2008 I have images on my image hosting site, and each image is ran through a PHP file. Using the PHP file, can I get the URL that the image is at, for example... If the image is at: http://myspace.com/username, I would like to read the exact URL, and save it into a database, so I can look at stats for my images. Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/ Share on other sites More sharing options...
discomatt Posted September 8, 2008 Share Posted September 8, 2008 I'm not exactly sure what you're trying to accomplish. Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636633 Share on other sites More sharing options...
The Little Guy Posted September 8, 2008 Author Share Posted September 8, 2008 See my Avatar? it is a face. that image is being shown from a PHP script (using .htacess). This page's URL is this: http://www.phpfreaks.com/forums/index.php/topic,215625.0.html. In my PHP file, I would like to connect to a database, read in the above http, and save it into my database. I would like to know... 1. would I have to use $_SERVER['SOME_VAL'] or is there something else I use? 2. can I get the url of the page that the image is on, or will it just show the images server (where the image came from)? Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636641 Share on other sites More sharing options...
discomatt Posted September 8, 2008 Share Posted September 8, 2008 Hm.. may I ask what you're using this for? Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636649 Share on other sites More sharing options...
The Little Guy Posted September 8, 2008 Author Share Posted September 8, 2008 To track where my images are being displayed, like I said in my first post. Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636659 Share on other sites More sharing options...
discomatt Posted September 8, 2008 Share Posted September 8, 2008 $_SERVER['HTTP_REFERER'] should contain the value... Try linking to this script <?php header( 'Content-Type: image/jpeg' ); $img = imagecreatetruecolor( '300', '35' ); $bg = imagecolorallocate( $img, 255, 255, 255 ); $text = imagecolorallocate( $img, 0, 0, 0 ); imagefill( $img, 0, 0, $bg ); imagestring( $img, 5, 10, 10, $_SERVER['HTTP_REFERER'], $text ); imagejpeg( $img ); imagedestroy( $img ); ?> Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636670 Share on other sites More sharing options...
The Little Guy Posted September 8, 2008 Author Share Posted September 8, 2008 HTTP_REFERER can be modified... Is there another way maybe, But I will give it a try. Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636681 Share on other sites More sharing options...
The Little Guy Posted September 8, 2008 Author Share Posted September 8, 2008 That does work, but if there is a way that doesn't use HTTP_REFERER, please let me know Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636689 Share on other sites More sharing options...
discomatt Posted September 8, 2008 Share Posted September 8, 2008 You're replying on client data.... so anything you get in that regard will be modifiable. When an image is downloaded it's a separate request, therefor its completely independent of the page with the <img> tag. If the client happens to send the page wit the <img> tag on it in the request, it'd show up as a referrer. Link to comment https://forums.phpfreaks.com/topic/123271-php-read-url-from-another-domain/#findComment-636733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.