Yep you read that right
ive got a small (haha) job on for a company where I need to upload files to various remote servers via FTP.
however the host they are using (Amen in France) seems to have nicely blocked all attempts to get this working.
They have told me that they disable the PHP FTP library, OK I say, how about cURL, no thats enabled … however try as I might I cant get any upload to initiate from this hosting account, if I move the script over to my servers it works fine.
Anyone got any clever ideas ? heres the simple upload script Im using
<?php
$ch = curl_init();
$localfile = "picture.jpg";
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, "ftp://user:pass@ftp.domaine.com/public/www/".$localfile);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$message = "File uploaded successfully.";
} else {
$message = "File upload error";
}
echo $message;
?>
I really wanted to keep it all on this server, my fallback plan would be a seperate script on my server that fetches the files then puts them on the remote servers, but thats getting messy.
TIA