A previous post of mine described an ftp_put issue that I later resolved. However, as Olaf suggested to me, now I am trying cURL because it turns out that my host has a size limit for that type of upload. I need to send files 50MB-100MB. (I did change all the parameters in php.ini, etc.)
Anyway, I'm brand new to cURL and have found many options but I'm not sure which all I need to use. Here is what I have and eventually it returns an error (but it's the same one my ftp_put returns, which is "2:filename cannot be empty".
$ch = curl_init();
$localfile = $_FILES['VideoLocation']['tmp_name'];
$fp = fopen($localfile, 'r');
$result = curl_setopt($ch, CURLOPT_URL, 'ftp://MyUserID:MyPassword@MyDomain.com/VideosApproved/'.$_FILES['VideoLocation']['name']);
// $result = curl_setopt($ch, CURLOPT_USERPWD, 'MyUserID:MyPassword');
$result = curl_setopt($ch, CURLOPT_PORT, 80);
$result = curl_setopt($ch, CURLOPT_INFILE, $fp);
$result = curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
$result = curl_setopt($ch, CURLOPT_UPLOAD, 1);
$result = curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_setopt($ch, CURLOPT_NOPROGRESS, 0); # to show progress meter ...
$result = curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0");
//the following line is where it just goes and goes and finally quits after about 20 minutes
$response = curl_exec ($ch); //Execute the session
$error_no = curl_errno($ch);
$error_msg = curl_error($ch);
curl_close ($ch); //Close the cURL session
if ($error_no == 0) {
echo "cURL uploaded the file succesfully.
";
} else {
die ("cURL had an upload error, error #".$error_no.$error_msg."
"."Response=".$response);
}
fclose($fp);