Page 1 of 1

PHP file transfer between servers?

Posted: Mon Dec 13, 2010 7:10 pm
by amazingrando
Hi everyone!

In our workflow we get new product images from a vendor's server each day. They put them up on a normal web page for anyone to download. I am trying to automate the process that we don't have to manually download a file each day and then upload to our server. Is there a PHP function similar to wget where I can request a certain file on a remote web page and have it saved to a directory on our server? Note that some files might be as large as 100MB.

Thanks!

Todd

Re: PHP file transfer between servers?

Posted: Mon Dec 13, 2010 7:45 pm
by Jonah Bron
Not to be presumptuous, but what's wrong with wget?

Re: PHP file transfer between servers?

Posted: Mon Dec 13, 2010 9:22 pm
by amazingrando
wget might be the best route. One of the problems I face is that the images I want to transfer are dynamically serviced with a URL like this: http://www.company.com/getimage.aspx?mediaid=785208. wget will correctly recognize it as an image of JPEG file type, but it saves it without an extension.

Maybe there's a better forum for this, but how would I get the mime type from wget and give the file the appropriate extension?

Re: PHP file transfer between servers?

Posted: Mon Dec 13, 2010 10:10 pm
by Jonah Bron
I just happen to know a bit about bash scripting :). If the file extension is a known constant (like .ISO), you can do it like this:

Code: Select all

wget -O outputfile.iso http://www.company.com/getimage.aspx?mediaid=785208