![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
Downloading an external image and saving it to disk
Hi all. I'm a maintainer for my school's website and recently, a teacher had put forward a request. He wants the website to download an image every hour and save it to disk.
This might be a stupid question, but is this sort of thing possible in PHP? I've attempted to put together something quickly using the copy() function and the Google logo, but I'm getting permission errors when I attempt to write the image to disk. Am I approaching this the correct way, or is there something that I'm missing? I'm not looking for a specific solution, but some general direction of how to proceed would be really appreciated. ![]()
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#2 |
|
Professional Programmer
|
Re: Downloading an external image and saving it to disk
Can you post your current code?
__________________
JG-Webdesign |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Re: Downloading an external image and saving it to disk
Make sure that you have access to write to that folder. Most the time on PHP servers the only access for the end users is read only. Run through your code and if you know that you are getting stopped at the writing part, chances are it's that the permissions have not been set up.
|
|
|
|
|
|
#4 | |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
Re: Downloading an external image and saving it to disk
Quote:
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
|
#5 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4
![]() |
Re: Downloading an external image and saving it to disk
I program in .Net so I'd more than likely make a service or shedule a task to run every hour and download on the server, is that possible for you to do?
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
Re: Downloading an external image and saving it to disk
There are operations for accessing an external web page internally. You could do this with raw sockets even if you have to (Connect to the server, Request the image, Receive the image, Cast some black magic).
Make sure to use the correct header information to request the image (GET /myimage.jpg HTTP/1.1\r\nHost: mywebsite.com\r\nContent-type: image/jpeg\r\n\r\n), and then use your file IO functions (Open File, Write to File, What the hell does this do?) with a binary write stream to save the image locally. Then, of course, automate this with an hourly crontab. Last edited by Sane; Nov 8th, 2007 at 12:06 AM. |
|
|
|
|
|
#7 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: Downloading an external image and saving it to disk
It would be much nicer if you could save the image to disk without writing to it, hmm?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| manipulating pixels of images and saving them on a file | diamondustice | Visual Basic | 0 | Feb 21st, 2006 9:00 PM |