My code to upload the file on the REMOTE server doesn't seem to be working. When uploading the file from the browser at the link, all the contents of csv file is committed to the database. Here is the code:
function postToDB()
{
$fp = fopen('./errorLog.txt', 'w+');
$csvFile = fopen('./myFile.csv', 'r');
$url="http://abc.com/UploadCSVLogin/";
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, ":password");
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $csvFile);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $fp);
if (!curl_exec($ch))
echo "Error: ".curl_error($ch);
else
echo "Success";
curl_close($ch);
}
Strangely, the code echoes "Success". But I don't find the database updates taking place with the code above even though "Success" is echoed.
Can anyone help me find the issue here?