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.
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.
