I can not upload file using CGI

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Peter@multidesk.se
Posts: 136
Joined: Fri Oct 14, 2011 6:53 am

I can not upload file using CGI

Post by Peter@multidesk.se » 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
/*Whats all the fuss with c# ?*/

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: I can not upload file using CGI

Post by Klaus » Wed Oct 22, 2014 12:04 pm

Hi Peter,

quick guess: Do K and gUID not need to be on QUOTES?
...
put "Content-Disposition: form-data; name=" & QUOTE & K & QUOTE & crlf after tData
put "Content-Disposition: form-data; value=" & QUOTE & gUid & QUOTE & crlf after tData
...
?


Best

Klaus

Peter@multidesk.se
Posts: 136
Joined: Fri Oct 14, 2011 6:53 am

Re: I can not upload file using CGI

Post by Peter@multidesk.se » Wed Oct 22, 2014 1:24 pm

Hi Klaus,

I've tried it, but it did not work so I removed them.
The only difference is that the database responds "One or more error occurred" or "Unsupported media type"

I'm stuck!

///Peter
/*Whats all the fuss with c# ?*/

Post Reply