Until runRev get there networking sorted out here is a way.
Prerequisite;
Access to a server that runs CGI verison 2.47 or higher (I don't even know what that means) unzip and upload to your cgi-bin folder
there are a couple of lines in there that need changing, upload folder and the url to your site.
I see I have the permissions set to 755
New stack with one button and one field on it
In the button put
Code: Select all
local tData,tPic,tName
on mouseUp
put "" into fld 1
if the environment is "mobile" then
set the vis of the templateImage to false
mobilePickPhoto "library"
put the last image into tPic
put "mobUp.jpg" into tName --someone fix this so the user can put there own filename in
else --desktop testing
answer file "Select a file to upload:" with filter "JPEGs,*.jpg"
put url ("binfile:"& it) into tPic
set itemDel to "/"
put the last item of it into tName
end if
put buildIt() into tData
post tData to URL "http://www.yourSite.com/cgi-bin/upload.pl" --where did you put the file?
put it into fld 1
set the httpHeaders to empty
set the vscroll of fld 1 to 1000
end mouseUp
Code: Select all
function buildIt
put "--__Part__" & crlf into tData
put "Content-Disposition: form-data; name=" & quote & "photo" & quote & "; filename=" & quote & tName & quote & crlf after tData
put "Content-Type: image/jpg" & crlf after tData
put "Content-Transfer-Encoding: binary" & crlf & crlf after tData
put tPic & crlf after tData
put "--__Part__--" after tData
put "Content-Type: multipart/form-data; boundary=" & quote & "__Part__" & quote into theHeader
set the httpHeaders to theHeader
return tData
end buildIt
Tested this on Android and iPad. I managed a 3.8 MB upload.
I'm using my on-rev sever but I don't think that should make a difference.
If the upload is successful "1 files successfully uploaded:" with the url to the file will be in the field down at the bottom (make it scrollable).
Warning: There is no security on this upload... I think there are bad people who can figure out how to abuse the CGI, fair warning. Maybe someone who knows more about CGI's will figure this out (Richard? ).
Oh Oh Oh... Be very careful if you mess with the buildIt function, mobile is very strict, just changing lowercase to capital letters finally made it work for me.
built using liveCode ver 6.5
Hope that it works for you.
Simon