I’m trying to upload a file to a distant server, but looks like the source file does nothing. All i get is a blank file on the server.
My code is this:
<?php
$c = curl_init();
$file = "\PATHTOFILE\file.txt";
$fp = fopen($file, "r");
curl_setopt($c, CURLOPT_URL, "SERVERPATH/file.txt");
curl_setopt($c, CURLOPT_USERPWD, "USER:PASSWORD");
curl_setopt($c, CURLOPT_UPLOAD, 1);
curl_setopt($c, CURLOPT_INFILE, $fp);
curl_setopt($c, CURLOPT_INFILESIZE, filesize($file));
curl_exec($c);
echo "Success";
curl_close($c);
fclose($fp);
?>
After 2 days of banging my head against the keyboard.. finally i did it..
Here is how:
Here is the source, from where i found the solution