Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Automatically Upload File to a Secure Server - CRON Job


lostdreamer - 3:12 pm on Mar 13, 2012 (gmt 0)


All of the above.

If there is a script on the other webserver which accepts a file upload, you can POST a file to it using curl


$ch = curl_init();
$fields = "img=@/path/to/image.jpg"
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec( $ch );
curl_close ($ch);


This will upload a file to the website using the variable name $_FILES['img']

Don't forget you need SSL installed as well as cURL.


If you have this script, you can call it from a cronjob like you suggested.


Thread source:: http://www.webmasterworld.com/php/4428604.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com