save picture to web server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
videogame
Forum Newbie
Posts: 11
Joined: Wed Jan 05, 2005 8:41 pm

save picture to web server

Post by videogame »

what script would i use to save a picture to my web server?

for example... i want to save http://www.google.com/image.gif

what script could save this to my web server and preserve directory structure?
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]curl[/php_man] is probably the more accurate answer you're looking for, if you want it automated. To keep the directory structure, you'll need to pull out each folder name and create those folders, if they don't already exist. Once you get the file from the request, you'll have to save it.

some functions to look into:
[php_man]explode()[/php_man] or [php_man]preg_split()[/php_man]
[php_man]opendir()[/php_man]
[php_man]mkdir()[/php_man]
[php_man]fopen()[/php_man]
Post Reply