$_POST uploaded $_FILES using cURL

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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

$_POST uploaded $_FILES using cURL

Post by kendall »

Hey guys,

I am creating an application which has a form that need to post results to a remote server.

On a $_FILES submission I need the posted $_FILE to be transported via cURL's POST. Research has shown that when passing files to cURL I need to

Code: Select all

array('datafile'=>'@/path/to/file'); 


but is it that I need to save the file to the server first? Is this the correct way to the transport the file? does cURL read and encode the file before sending off? or does the end app get the path for it to read?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: $_POST uploaded $_FILES using cURL

Post by John Cartwright »

If you have the file in your $_FILES array, it already is on your filesystem. The only difference is it's being stored in a temporary location, which will be cleaned up after your garbage collector runs. You can simply pass the tmp location (which is found in the $_FILES array) to cURL.
does cURL read and encode the file before sending off? or does the end app get the path for it to read?
cURL will read it, and send it off in TCP connection as bytes. There is no "encoding" going on. The end app then reads the bytes on the stream (and saves them) to download the file.
Post Reply