Page 1 of 1

mobilePickPhoto Save the Photo

Posted: Tue Jan 19, 2021 2:59 am
by JereMiami
After picking the photo from the android album or library, how do you save it to specialFolderPath("resources") or a subfolder therein, such as "images?"

What am I missing here ...

Code: Select all

if the environment is "mobile" then
      mobilepickPhoto "album"
      if the result <> EMPTY then
         answer "Error:" && the result
         exit mouseup
      end if
      put the text of last image into tData
      put base64encode(tData) into tBase
      set the text of img "customPhoto" of grp "pickPhoto" to tData
      set the defaultFolder to specialFolderPath("resources")
      put last image into url ("binfile:" & "sample.jpg")
      set the vis of grc "background" of grp "pickPhoto" to false
      set the vis of fld "field" of grp "pickPhoto" to false
      set the vis of img "customPhoto" of grp "pickPhoto" to true
      delete last img
 end if 

Re: mobilePickPhoto Save the Photo

Posted: Tue Jan 19, 2021 8:41 am
by SparkOut
The short answer, specialFolderPath("resources") is read only.
On mobile, you will need to write to specialFolderPath("documents") instead.
If necessary, "resources" bundled with the standalone builder will need to be copied to "documents" on first run of the app.

Re: mobilePickPhoto Save the Photo

Posted: Tue Jan 19, 2021 3:20 pm
by JereMiami
Correct. Thanks so much. I totally forgot that it was read only. The following code successfully: (1) allows the user to select from the mobile album; (2) places the jpg image into an image object on the card; and (3) saves the image to the specialFolderPath("documents") folder in the standalone sandbox, where it can be uploaded to a server, and I have tested that the jpeg is received intact.

Thanks- It was driving me nuts.

Code: Select all

on mouseUp
   if the environment is "mobile" then
      mobilepickPhoto "album"
      if the result <> EMPTY then
         answer "Error:" && the result
         exit mouseup
      end if
      put the text of last image into tData
      put base64encode(tData) into tBase
      set the text of img "customPhoto" of grp "pickPhoto" to tData
      set the defaultFolder to specialFolderPath("documents")
      put last image into url ("binfile:" & "photo.jpg")
      set the vis of grc "background" of grp "pickPhoto" to false
      set the vis of fld "field" of grp "pickPhoto" to false
      set the vis of img "customPhoto" of grp "pickPhoto" to true
      put specialFolderPath("documents") & "/photo.jpg" into tPath
      delete last img
   end if
end mouseUp