This Question is Possibly Answered

1 "correct" answer available (8 pts) 15 "helpful" answers available (5 pts)
3 Replies Last post: Nov 18, 2008 8:58 PM by Duke  
ABC XYZ BlackBelt 285 posts since
Mar 6, 2008
Currently Being Moderated

Nov 17, 2008 7:33 AM

Wired with File Upload

Hi

I'm really wired with uploading a file to server. My simple HTML version of file upload works perfectly fine, but the same version of Curl is NOT working

Below is my HTML code which works perfectly ...

<html>
<body>
<form action="http://www.xyz.com/compose.xml" method="post" enctype="multipart/form-data">
     Session id:<input type=text name="sessionid" value="5b23e58xxx90d50d3f8913b51e21eccf9"><br>
     op:<input type=text name="op" value="send"><br>
     to:<input type=text name="to" value="u2"><br>
     subject:<input type=text name="subject" value="My Subject"><br>
     message:<input type=text name="message"><br>
     attachment:<input type=file name="attachs"><br>
     <input type=submit value=submit><br>
</form>
</body>
</html>

 

And in my curl version of http-form I'm doing and ensuring the following things .....

1. action = http://www.xyz.com/compose.xml

2. method = HttpRequestMethod.post

3. encoding = HttpFormData.multipart-mime-type

4. On browse command button selecting a file with {choose-file}

5. Before submitting the form adding the file to form as {cb.form.add-file "attachs", {non-null my-file-url}}

 

Below is my Curl code ...


{let fileURL:#Url}
{let txtSID:TextField = {TextField name= "sessionid", value="5b23e58xxx90d50d3f8913b51e21eccf9"}}
{let txtOP:TextField = {TextField name="op", value="send"}}
{let txtTO:TextField = {TextField name="to", value="u2"}}
{let txtSubject:TextField = {TextField name="subject", value="My Subject"}}
{let txtMessage:TextField = {TextField name="message", value=""}}
{let cmdBrowse:CommandButton =
    {CommandButton
        label="Browse",
        {on Action do
            set fileURL = {choose-file}
        }
    }
}

{value
    let myForm:HttpForm =
        {HttpForm
            {url "http://www.xyz.com/compose.xml"},
            method = HttpRequestMethod.post,
            encoding = HttpFormData.multipart-mime-type,
            {spaced-vbox
                txtSID,
                txtOP,
                txtTO,
                txtSubject,
                txtMessage,
                cmdBrowse,
                {CommandButton
                    label = "Sumit",
                    {on Action at cb:CommandButton do
                        {cb.form.add-file "attachs", {non-null fileURL}}
                        {cb.form.submit}
                    }
                }
            }
        }
    myForm
}

Still, the file is not getting uploaded to server and server returns an error

 

Thank you.

Duke BlackBelt 297 posts since
Oct 17, 2007
Currently Being Moderated
1. Nov 17, 2008 5:29 PM in response to: ABC XYZ
Re: Wired with File Upload

I don't notice anything wrong by reading your code, but I could be missing something.  Is your server giving any kind of informative error message?

 

There was a similar thread a few months ago which you should read, How to upload a file on server along with HttpForm?.  You might be having a similar problem which we thought was on the server side - note one of the last comments that says "Your server must be sensitive to some small difference in the messages being sent."

 

You can try the sample file upload demo to a Curl server.  In the earlier message thread, I said

===

Have you tried using a packet sniffer to see what is going on? This sounds like a server side problem. Your Curl code looks like the example file upload code you can find at http://www.curl.com/developers/httpforms/file-upload.curl. You can look at that applet (or any applet's code) by using ctrl+right-click and choosing Edit Applet Source with the Curl IDE.

===

 

If the demo upload works for you, that tells us that the problem is at least somewhat server dependent.

Rajiv Level 7 118 posts since
Apr 3, 2008
Currently Being Moderated
2. Nov 18, 2008 1:34 AM in response to: Duke
Re: Wired with File Upload

Hi Duke, what is the <font color="#ff0000"> *Content-transfer-encoding*</font>, when attached file data  is posted to server?Is it   <font color="#ff0000">*base64*</font>  or  some other format.ThanksRajiv

Duke BlackBelt 297 posts since
Oct 17, 2007
Currently Being Moderated
3. Nov 18, 2008 8:58 PM in response to: Rajiv
Re: Wired with File Upload

Looking at the packets for that file-upload.curl demo I mention above, the  Content-transfer-encoding is binary

More Like This

  • Retrieving data ...