Jump to content

[SOLVED] get an image or file from other server(site)


asmith

Recommended Posts

Something like this, if you have allow_url_fopen set to On:

 

<?php
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11');
$url = 'http://example.com/image.jpg';
//save the remote file as 'image.jpg' in same directory as this script
file_put_contents(basename($url), file_get_contents($url));
?>

 

I set the user agent string to bypass the check that some sites do.

Thanks man. Thanks a lot :)

 

My own code was this :

<?php
$url = 'http://example.com/image.jpg';
//save the remote file as 'image.jpg' in same directory as this script
file_put_contents(basename($url), $url);
?>

 

Dunno why I never thought I file_get first XD

 

 

 

 

 

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.