PHP Upload file from URL

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
agurchand
Forum Newbie
Posts: 1
Joined: Sat Jan 05, 2013 9:34 am

PHP Upload file from URL

Post by agurchand »

Do you know only one line of code will upload a image or file from a URL?
check this out:

Code: Select all

file_put_contents("uploads/$name", file_get_contents($url);
Please give your comments about this program friends.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Upload file from URL

Post by social_experiment »

technically you'd be making a copy of the file; what do you intend to use the script for?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Upload file from URL

Post by requinix »

copy() would be even easier.
Post Reply