Jump to content

PHP Read URL From another Domain...


The Little Guy

Recommended Posts

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

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)?

$_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 );

?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.