I can not upload file using CGI
Posted: Wed Oct 22, 2014 11:45 am
I did not manage to upload files to my database. Does anyone have any idea. What happens is that the database responds "Unsupported media type" It is a common SQL database, so it should not be that tricky.
This is the html form:
<form action="api/upload" method="POST" enctype="multipart/form-data">
<input type="text" name="k" value="88C9607F-4A89-447D-97C4-BC124DDA7DBF” />
</form>
And this is what I try to do:
local tData,tPic
constant gUid = "88C9607F-4A89-447D-97C4-BC124DDA7DBF" -- just for test
on mouseUp
set the vis of the templateImage to false
mobilePickPhoto "library"
put the last image into tPic
put buildIt() into tData
post tData to URL myUrl
answer it-- just for test
set the httpHeaders to empty
end mouseUp
function buildIt
put "Content-Disposition: form-data; name=" & K & crlf after tData
put "Content-Disposition: form-data; value=" & gUid & crlf after tData
put tPic & crlf after tData
put "Content-Type: multipart/form-data; boundary=" into theHeader
set the httpHeaders to theHeader
return tData
end buildIt
What am I doing wrong?
/// Peter
This is the html form:
<form action="api/upload" method="POST" enctype="multipart/form-data">
<input type="text" name="k" value="88C9607F-4A89-447D-97C4-BC124DDA7DBF” />
</form>
And this is what I try to do:
local tData,tPic
constant gUid = "88C9607F-4A89-447D-97C4-BC124DDA7DBF" -- just for test
on mouseUp
set the vis of the templateImage to false
mobilePickPhoto "library"
put the last image into tPic
put buildIt() into tData
post tData to URL myUrl
answer it-- just for test
set the httpHeaders to empty
end mouseUp
function buildIt
put "Content-Disposition: form-data; name=" & K & crlf after tData
put "Content-Disposition: form-data; value=" & gUid & crlf after tData
put tPic & crlf after tData
put "Content-Type: multipart/form-data; boundary=" into theHeader
set the httpHeaders to theHeader
return tData
end buildIt
What am I doing wrong?
/// Peter