| 7:36 pm on Jun 3, 2003 (gmt 0)|
Since no one seems to have any grand insight the first things that come to mind are curl, GD or a socket. Haven't done anything like that really though.
I just get them to upload from their hard drive.
| 7:37 pm on Jun 3, 2003 (gmt 0)|
Yes, I may just try it out to see if it'll work with a 'browse' button on a form.....
| 7:39 pm on Jun 3, 2003 (gmt 0)|
actually, saying that, there are lots of file functions that open urls etc, why would an image be any different?
If I could open the image and save it to a var then........ I'll have to think about this ;)
| 7:42 pm on Jun 3, 2003 (gmt 0)|
which is why I thought of curl. If you want to open a remote opage somewhere that is how to do it. Then when saving it you may need to use GD to test the type and then save/create a new image.
| 7:45 pm on Jun 3, 2003 (gmt 0)|
just my $0.02
curl and such are quite slow
| 7:46 pm on Jun 3, 2003 (gmt 0)|
what would you suggest then Gibble?
| 7:47 pm on Jun 3, 2003 (gmt 0)|
I don't have root. Curls an add on right?
| 7:58 pm on Jun 3, 2003 (gmt 0)|
Yea, cURL [curl.haxx.se] is a command line program. Easiest way to run it from PHP is using one of the backtick-type commands.
% curl h-ttp://server.tld/image.gif > image.gif
| 8:04 pm on Jun 3, 2003 (gmt 0)|
If you want to use cURL with PHP
I don't know what to recommend, I just know it's not fast :(
I suppose you could use wget from the command line...
[edited by: jatar_k at 8:12 pm (utc) on June 3, 2003]
[edit reason] delinked [/edit]
| 8:10 pm on Jun 3, 2003 (gmt 0)|
I can execute command line apps from PHP?
| 8:43 pm on Jun 3, 2003 (gmt 0)|
yes, there's a few different ways to execute a shell program via PHP. Take a look at the 'passthru' function which I *think* would be the most appropriate for what you're trying to do. All of the methods are listed here [us3.php.net]
| 8:54 pm on Jun 3, 2003 (gmt 0)|
If you want to do command line, you could also to wget:
will get the file at the specified url and dump it into your current directory. to specify a directory and name, use
wget --output-document=<filename> <url>
You can also use --limit-rate=20kb for example to limit the max download rate at 20kb if you dont want to paralyze your server or the remote server. There are also options for specifying lists of files and such, just use the man page.
Also, php can directly download files on it's own and also write them:
fopen works the same on remote urls as local files if you are reading. Works for images just fine. Now the trick then becomes finding all the image urls.
| 11:25 pm on Jun 3, 2003 (gmt 0)|
Wouldn't it be the most straightforward way to use a php function to read the contents of a URL (i.e. the picture file) into a variable? There is file_get_contents() as of PHP 4.3 (see php docs). I haven't used it yet but it sounds like the one that you want.
| 3:14 am on Jun 4, 2003 (gmt 0)|
Why not just use GD? [us2.php.net...]
|imagecreatefromgd2 -- Create a new image from GD2 file or URL |
imagecreatefromgd2part -- Create a new image from a given part of GD2 file or URL
imagecreatefromgd -- Create a new image from GD file or URL
imagecreatefromgif -- Create a new image from file or URL
imagecreatefromjpeg -- Create a new image from file or URL
imagecreatefrompng -- Create a new image from file or URL
imagecreatefromstring -- Create a new image from the image stream in the string
imagecreatefromwbmp -- Create a new image from file or URL
imagecreatefromxbm -- Create a new image from file or URL
imagecreatefromxpm -- Create a new image from file or URL