Update of /cvsroot/curl/curl-www/libcurl/php/examples
In directory labb:/tmp/cvs-serv24034
Modified Files:
ftpupload.php
Log Message:
rectified the ftpupload script somewhat
Index: ftpupload.php
===================================================================
RCS file: /cvsroot/curl/curl-www/libcurl/php/examples/ftpupload.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ftpupload.php 13 Nov 2005 09:36:32 -0000 1.1
+++ ftpupload.php 9 Jun 2006 07:44:05 -0000 1.2
@@ -4,18 +4,19 @@
//
$ch = curl_init();
+$localfile = "me-and-my-dog.jpg"
+
+$fp = fopen ($localfile, "r");
// we upload a JPEG image
curl_setopt($ch, CURLOPT_URL,
"ftp://mynamw:[email protected]/path/to/destination.jpg");
curl_setopt($ch, CURLOPT_UPLOAD, 1);
-curl_setopt($ch, CURLOPT_INFILE, "me-and-my-dog.jpg");
+curl_setopt($ch, CURLOPT_INFILE, $fp);
// set size of the image, which isn't _mandatory_ but helps libcurl to do
-// extra error checking on the upload. If you can tell me how to get filesize
-// nicely with a PHP function then I'd like to add it here to make the example
-// better!
-curl_setopt($ch, CURLOPT_INFILESIZE, 3271);
+// extra error checking on the upload.
+curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
$error = curl_exec ($ch);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.