| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-and-php Archives
Reading/Writing to the same file via FTP...
From: -Sys Adm- <centralsource_at_hotmail.com>
Date: Thu, 15 Dec 2011 20:41:19 -0500
All I need to do in PHP is:
READ the contents of a file on my FTP server. (Contents of file are only a single number, 0 - 12)
I am currently READING the contents of the file and adding that to a $variable perfectly using this function:
$expire = "filename";
function read_file($expire)
As far as WRITING the $new_content variable back to the same file, I am completely lost on finding any examples of this....
My assumption would be:
$expire = "filename";
function write_file($expire)
curl_setopt($curl, CURLOPT_URL, "ftp://"location"/".$expire);
curl_setopt($curl, CURLOPT_USERPWD, "U:P");
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//this is where I am completely lost...
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$data = curl_exec($curl);
curl_close($curl);
if ($data != false){
return $data;
}else{
echo 'ERROR';
}
I have read that cURL does NOT need the fopen, fwrite, fclose calls in order to write data to a file? And I have also read about the CURLOPT_WRITEFUNCTION call, and that is where I am not sure how to WRITE the new contents of the $new_contents variable???
A simple example on the cURL PHP example would be wonderful.
I apologize in advance for my lack of PHP or cURL knowledge. I am working on this project for a commercial business, and I am the smartest one employed here!!
Thanks in advance...
_______________________________________________
These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info