There are numerous post in regards  to uploading via a web form but most are CGI and/or Livecode Server.  I am not using Livecode server so I have been struggling to create an upload solution for photos from all mobile systems including android.  I have a PHP form now working.  
I tried to adapt Simon's code in post -http://forums.runrev.com/viewtopic.php?f=8&t=19144, but either this will not work with PHP or I am just doing something seriously wrong.
I am at a dead end...anyone have any ideas what the LiveCode App end of this should look like to feed this web form?
			
			
									
									
						Uploading to server via PHP form
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Uploading to server via PHP form
Sorry forgot to add what I have so far - 
			
			
									
									
						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
      put tPic into field "bin" --just for me
      
      set itemDel to "/"
      put the last item of it into tName
      
   end if
   put buildIt() into tData 
   put tData into field "build" --just for me
   post tData to URL "http://www.mysite.com/upload_file.php" --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
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 buildItRe: Uploading to server via PHP form
Figured it out.  It was all in the header
Now works like a dream
			
			
									
									
						Code: Select all
   put "Content-Disposition: form-data; name=" & quote &"file"& quote & "; fileName=" & quote & tName & quote & crlf after tDataRe: Uploading to server via PHP form
Hello,
Thanks for posting this solution - works great on desktop (Mac at least).
However, a post or put call when httpHeaders is set will crash my iOS app.
If I leave httpHeaders empty, the php script will go on but of course no file will be uploaded.
iOS 8.1.3, LC 7.0.0 commercial.
I reported it as a bug (Bug 15102) but maybe I can get more info here (not sure if QA works the weekends..).
Thanks
			
			
									
									
						Thanks for posting this solution - works great on desktop (Mac at least).
However, a post or put call when httpHeaders is set will crash my iOS app.
If I leave httpHeaders empty, the php script will go on but of course no file will be uploaded.
iOS 8.1.3, LC 7.0.0 commercial.
I reported it as a bug (Bug 15102) but maybe I can get more info here (not sure if QA works the weekends..).
Thanks

