POST (mulitpart/form-data)

Harald Müller harald at etcpp.de
Fri Dec 10 07:37:25 EST 2010


Hi all,

I'm trying to build a mulitpart/form-data post, but it doesn't work. I don't
want to use libUrlMultipartFormData because I don't think it would work
on the iPhone. Any idea? My test-script:

on mouseUp
   answer file "Testfile:" of type "PNG"
   Put url ("binfile:/" & it) into myFile
   put makeMultipart(myFile) into myFile
   post myFile to URL "http://www.server.com/upload.php"
   answer it
end mouseUp

function makeMultipart myFile
   -- build header
   put "POST /upload.php HTTP/1.0" & return into myHeader
   put "Host: www.server.com" & return after myHeader
   put "Date: " & the internet date & return after myHeader
   put "Content-Type: multipart/form-data; boundary=uploadToHost" & return after myHeader
   put "Content-Length: " & (the number of chars of myFile) & return after myHeader
   put return after myHeader
   set the httpHeaders to myHeader
   -- build data
   put "--uploadToHost" & return into myContainer
   put "Content-Disposition: form-data; name=" & quote & "test.png" & quote & return after myContainer
   put "Content-Type: image/png" & return after myContainer
   put "Content-transfer-encoding: binary" & return after myContainer
   put return after myContainer
   put myFile & return after myContainer
   put "--uploadToHost--" & return after myContainer
   return myContainer
end makeMultipart

Best regards,
Harald Müller.



More information about the Use-livecode mailing list