Forum Moderators: coopster

Message Too Old, No Replies

saving images using php and the images url

how to store the image in db or folder using php

         

proper_bo

3:03 pm on Jan 11, 2006 (gmt 0)

10+ Year Member




Can someone point me in the right direction please.

How do I go from having the images URL to putting a copy of the image in a folder or db.

Thank you.

proper_bo

4:24 pm on Jan 11, 2006 (gmt 0)

10+ Year Member




I found this:

$url = 'http://www.domain.com/image.jpg';
$localfile = 'mydir/image.jpg';
copy($url, $localfile);

incase anyone comes here looking for an answer.
If you can't get that to work then try this:

$url = 'http://www.domain.com/image.jpg';
$data = file_get_contents($url);
$handle = fopen(basename($url), 'w');
fwrite($handle, $data);
fclose($handle);