How to POST an image file?

Joel Guillod joel.guillod at net2000.ch
Mon May 7 12:01:41 EDT 2007


Given the following form in an html page from url like "http:/ 
myserver/mydir/mypage":

<form action="myaction" method="post"
enctype="multipart/form-data">
<p>File: <input type="file" name="file"></p>
<input type="submit">
</form>

I try to "POST tData to URL "http:/myserver/mydir/mypage/myaction"
where tData contains the following data:

--> (this line is not included in data)
Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="file"; filename="logo.gif"
Content-type: image/gif
Content-Transfer-Encoding: binary

GIF89a DATA HERE...
--AaB03x--

<-- (this line is not included in data)

Can anyone tell me why I get a 500 server error or a 40x error? Using  
the original html page in a web browser works as expected and I have  
checked that it is not a cookie issue.

I also tried without success (same error) with the following tData:

--> (this line is not included in data)
Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="file"
Content-type: multipart/mixed, boundary=BbC04y

--BbC04y
Content-disposition: attachment; filename="decoration.gif"
Content-type: image/gif
Content-Transfer-Encoding: binary

GIF89a DATA HERE...
--BbC04y--
--AaB03x--

<-- (this line is not included in data)

So I suppose either my post url or the data content is/are  
malformed... Any help welcome!

Thanks,
Joel


More information about the use-livecode mailing list