Page 1 of 1

$_POST uploaded $_FILES using cURL

Posted: Thu Jan 20, 2011 7:08 am
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?

Re: $_POST uploaded $_FILES using cURL

Posted: Thu Jan 20, 2011 3:30 pm
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.