LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 298 users online 172460 members 443 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
4 online / 16 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Downloading files in php
Replies: 5Last Post Sep. 8, 2007 6:58pm by Robert89
Single page for this topic Email Print Favorite
( pleaseremove )


Dairy Product Addict

Patron
Tech Support Leader
Reply
OK, i want to write some code to take an image path and download the file and save it under a filename from a var i set and then allows me to store the full new filename (so including whatever the extension is) so it can be called from my own server.

In other-words, its something to allow me to use images from other sites, but without hot-linking and using their bandwidth. I would rather host locally and then link to them.

Any ideas?

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


5:15 pm on Sep. 4, 2007 | Joined Feb. 2005 | 1085 Days Active
Join to learn more about pleaseremove England, United Kingdom | Straight Male | 5432 Posts | 29086 Points
Post from this position was omitted due to content violations
The Dalai Lama


Soothsayer

Patron
Reply
Well you can probably just use file_get_contents("http://xyz.com/xyz.jpg"); and then use the fwrite to add it to your server.


-------
READ THIS
MP3 UPLOADZZZ

5:19 pm on Sep. 4, 2007 | Joined Oct. 2006 | 471 Days Active
Join to learn more about The Dalai Lama Ontario, Canada | Straight Male | 8782 Posts | 12000 Points
drifting


God Damn This Mess That is Me

Patron
Reply
Like have it grab the image and download it, right?

I would like something like that to, it would be useful.

-------
We are the result of your laws.
We are the result of your democracy.
We are the result of your corruption.


5:32 pm on Sep. 4, 2007 | Joined Jan. 2007 | 403 Days Active
Join to learn more about drifting Indiana, United States | Straight Male | 10219 Posts | 24683 Points
( pleaseremove )


Dairy Product Addict

Patron
Tech Support Leader
Reply
Ended up using:
Code:

$new = 'test.jpg';
$old = "http://www.testimage.com/yey.jpg";
$temp = file_get_contents($old);
$handle = fopen($new, "x");
fwrite($handle, $temp);
fclose($handle);


-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?

6:57 pm on Sep. 4, 2007 | Joined Feb. 2005 | 1085 Days Active
Join to learn more about pleaseremove England, United Kingdom | Straight Male | 5432 Posts | 29086 Points
Robert89


Wealthy Hobo

Patron
Tech Support Leader
Reply
Interesting... I may have to use this code. Anybody know how to make it so that a user can upload images directly from their computer onto the web site using PHP? I'm guessing it's probably similar to the above code... so any help would be appreciated.

-------
The difference between genius and stupidity is that genius has its limits.
-- Albert Einstein

6:58 pm on Sep. 8, 2007 | Joined Sep. 2006 | 249 Days Active
Join to learn more about Robert89 Pennsylvania, United States | Label Free Male | 900 Posts | 5811 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic