Page 1 of 1

Save a file from another server

Posted: Sat Feb 11, 2006 4:37 pm
by jwalsh
Hey guys,

We've written an RSS import feed which takes a given rss feed, strips most tags, except links, images, and a few other things.

We have an issue with images. We can link to the existing file on someone elses server just fine, but to avoid being a bandwidth theif, I'd like to download that image to our server, and link to it locally.

Any ideas how I can do this download transfer? Something with sockets I assume?

Thanks,

Josh

Posted: Sat Feb 11, 2006 4:45 pm
by feyd
file_get_contents('http://the file')
fopen()-fwrite()-fclose()
str_replace() the original url with your now internalized copy.

Posted: Sat Feb 11, 2006 5:01 pm
by jwalsh
Much easier than I thought, works like a charm.

Feyd, you never cease to amaze.