PHP file transfer between servers?

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
amazingrando
Forum Newbie
Posts: 2
Joined: Mon Dec 13, 2010 7:01 pm

PHP file transfer between servers?

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP file transfer between servers?

Post by Jonah Bron »

Not to be presumptuous, but what's wrong with wget?
amazingrando
Forum Newbie
Posts: 2
Joined: Mon Dec 13, 2010 7:01 pm

Re: PHP file transfer between servers?

Post 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?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP file transfer between servers?

Post 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
Post Reply