Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-24-2010, 12:42 AM   PM User | #1
bluemoonballoon
New to the CF scene

 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
bluemoonballoon is an unknown quantity at this point
Absolute path of remote images

I'm building a site for a client that has a feature similar to the way Facebook grabs images from a url you enter (ajax?). I've tried for days and I can't seem to find a simple way to get absolute image paths from a remote url. I can get the relative ones just fine, though.

Any thoughts? This is driving me nuts.
bluemoonballoon is offline   Reply With Quote
Old 02-24-2010, 02:13 AM   PM User | #2
iLochie
Regular Coder

 
Join Date: Jan 2010
Posts: 101
Thanks: 17
Thanked 5 Times in 5 Posts
iLochie is an unknown quantity at this point
Quote:
Originally Posted by bluemoonballoon View Post
I'm building a site for a client that has a feature similar to the way Facebook grabs images from a url you enter (ajax?). I've tried for days and I can't seem to find a simple way to get absolute image paths from a remote url. I can get the relative ones just fine, though.

Any thoughts? This is driving me nuts.
Get the address from the user inputed URL (such as http://google.com) and append the relative image path (images/image.gif):
Code:
$url = $_GET['url'];
$image_path = "images/image.gif";
if(file_get_contents($url)){
     $url += $image_path;
}
There's probably better ways of doing it, and of course you'd have to check to make sure there are no variables and such attached to the url.
iLochie is offline   Reply With Quote
Old 02-24-2010, 03:25 AM   PM User | #3
bluemoonballoon
New to the CF scene

 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
bluemoonballoon is an unknown quantity at this point
That works fine unless you have an image path like this: "../../images/01.jpg"
bluemoonballoon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:51 AM.


Advertisement
Log in to turn off these ads.