![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hi! I use Curl (libcurl 7.9.8 /OpenSSL 0.9.6g ) in PHP (Version 4.3.0 ) on Windows 2000 Server platform (IIS web server). Everything is working as expected. I would like to transfer a file to ftp site using Curl. As stated in the PHP Curl FAQ: **************************** 5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ? Yes, but you cannot open a FILE * and pass the pointer to a DLL and have that DLL use the FILE *. If you set CURLOPT_FILE you must also use CURLOPT_WRITEFUNCTION as well to set a function that writes the file, even if that simply writes the data to the specified FILE*. Similarly, if you use CURLOPT_INFILE you must also specify CURLOPT_READFUNCTION. **************************** I have no idea how the function specified in CURLOPT_READFUNCTION option should look like !?! My code is: ************************ <html><head><title>whatever</title></head> <body> <?php // Here I should put file data that should be sent to FTP server ?!? function read_body($ch, $string) { $len = strlen($string); return $len; } $post="POST"; $url = "ftp://user $filename = "D:\\test1.txt"; if (!$handle = fopen($filename, 'r')) { print "Cannot open file ($filename)"; exit; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 1 ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_READFUNCTION, "read_body" ); curl_setopt($ch, CURLOPT_FTPASCII, 1); curl_setopt($ch, CURLOPT_INFILE, $handle ); curl_setopt($ch, CURLOPT_INFILESIZE, filesize( $filename ) ); curl_exec($ch); curl_close($ch); fclose ($handle); ?> </body></html> ************************ If I execute it, after a few minutes I receive a Timeout error message on screen without any data Please help me write this TXT file to FTP server using CURL in PHP on Windows. Best regards Stefan | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: curl, curlopt_readfunction, option, php, problems, using |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cURL and redirection in php | D Benfer | PHP | 0 | 07-01-2007 3:51 PM |
| cURL and Snoopy | Nikolai Petkov | PHP | 0 | 07-01-2007 3:41 PM |
| curl + xml post | Barry B | PHP | 1 | 07-01-2007 3:34 PM |
| PHP & Authorize.net w/o cURL? | William C. White | PHP | 3 | 07-01-2007 3:13 PM |
| The page curl effect on Spotfire.com | Quick Function | Graphics in general | 4 | 06-11-2007 8:04 PM |
| Featured Websites | ||||
|