cURL / Mailing Lists / curl-library / Single Mail

curl-library

Is there a size limit on using CURLFORM_FILE

From: Max L. Eidswick <max_at_eidswick.com>
Date: Tue, 22 Jul 2008 11:05:56 -0600

Is there a size limit on using CURLFORM_FILE when sending simple http uploads?

I have tried a simple test and it works up to around 4MB and then odd things happen like zero bytes uploaded or the FILESPEC form
field NULL.

----- snip -----

        // -------------------------------------------------------------
        res = curl_formadd ( // add field/value for test
                &formPostSendFile, // the form to add to
                &lastPtr, // managed by formadd
                CURLFORM_COPYNAME, "FILESPEC", // from PHP script
                // set the value of "filename" to src
                CURLFORM_COPYCONTENTS, // actually copy the field
                szDestinationFilespec, // our target file specification
                CURLFORM_END
                                  ) ; // per libcurl spec

        // -----------------------------------------------------------------
        // setup a simple sendfile form, the php script simply copies the
        // uploaded file and creates an upload logfile entry for testing
        // -----------------------------------------------------------------
        res = curl_formadd ( // add field/value for sendfile/callback test
                &formPostSendFile, // libcurl form for sendfile
                &lastPtr, // managed by formadd
                CURLFORM_COPYNAME, "LOCALFILE", // field name
                CURLFORM_FILE, szLocalFilespec, // HTTP upload
                CURLFORM_END
                                  ) ; // per libcurl spec

        // -------------------------------------------------------------
        // Tells libcurl you want a multipart/formdata HTTP POST to be
        // made and you instruct what data to pass on to the server.
        // Pass a pointer to a linked list of curl_httppost structs as
        // parameter. . The easiest way to create such a list, is to
        // use curl_formadd(3) as documented. The data in this list must
        // remain intact until you close this curl handle again with
        // curl_easy_cleanup(3).
        // -------------------------------------------------------------
        res = curl_easy_setopt ( curlhSendFile, CURLOPT_HTTPPOST,
                                                        formPostSendFile ) ;

        // -------------------------------------------------------------
        // check the msecs before and after the call to easy perform
        ulStartTick = GetTickCount ( ) ; // keep track of elapsed time
        res = curl_easy_perform ( curlhSendFile ) ; // << -- BOOM !!!
        ulEndTick = GetTickCount ( ) ; // end timer millisecond tick
        ulSendFilePerformMSecs = ulEndTick - ulStartTick ; // n msecs

----- snip -----
Received on 2008-07-22