i have a question on cURL... The following code does everything its supposed to do ... upload an image file from my local machine to the web server. however when i look at the image on the server it does not show... although the filesizes are the same on both my local machine and on the server... does anyone know why this is happening... it only causes an error when it is an image file normal text files are fine...
Code: Select all
<?php
$curl = curl_init();
$file = "file://path/to/image.jpg";
$fp = fopen($file, "rb");
curl_setopt($curl, CURLOPT_URL,"ftp://path/to/server/image.jpg");
curl_setopt($curl, CURLOPT_USERPWD, "username:password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_UPLOAD, 1);
curl_setopt($curl, CURLOPT_INFILE, $fp);
curl_setopt($curl, CURLOPT_INFILESIZE, filesize($file));
curl_setopt($curl, CURLOPT_FTPASCII, 1);
curl_exec($curl);
curl_close ($curl);
?>