Upload JPEG

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Upload JPEG

Post by bsouthuk » Fri Apr 09, 2010 12:44 pm

Hello Rev users!

I've built an application in Studio and I want a user to be able to upload a Jpeg or bitmap image to a card. Is this simply done?

Your help is as always, much appreciated.

Cheers

Daniel

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Upload JPEG

Post by Mark » Fri Apr 09, 2010 3:33 pm

Hi daniel,

This is easy to do, but you can't save the changes in a standalone. There are several ways to do this.

1) Create a new image object and set the filename of the image object to the path to your file
2) Create a new image object and set the text of the image object to the contents of your file
3) Use the import paint command

You can do all this by script.

Best,

Mark
Last edited by Mark on Fri Apr 09, 2010 3:46 pm, edited 1 time in total.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upload JPEG

Post by jmburnod » Fri Apr 09, 2010 3:44 pm

Hi Daniel

You can use this script

Code: Select all

on mouseup
   ImportPicture
end mouseup

on ImportPicture
   answer file "Choose an image" 
   if it = empty then
      exit ImportPicture
   end if
   put it into TheFile
   import paint from file TheFile
end ImportPicture
Best

Jean-Marc
https://alternatic.ch

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Upload JPEG

Post by bsouthuk » Fri Apr 09, 2010 4:22 pm

Thats excellent thank you so so much for the script.

What script would I need to delete/clear the images that have been uploaded?

Cheers

dan

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upload JPEG

Post by jmburnod » Sat Apr 10, 2010 8:58 am

Daniel,


If the script import the imagefile by "import"

Code: Select all

on ImportPicture
   answer file "Choose an image"
   if it = empty then
      exit ImportPicture
   end if
   put it into TheFile
   import paint from file TheFile
end ImportPicture
you can delete the last img

Code: Select all

delete last img
If the script use the filename (an image "MyImage" exists on the card)

Code: Select all

on ImportPicture
   answer file "Choose an image"
   if it = empty then
      exit ImportPicture
   end if
   put it into TheFile
   set the filename of img "MyImage" to TheFile
end ImportPicture
You can clearing the image

Code: Select all

set the filename of img "myImage" to empty
Best

Jean-Marc
https://alternatic.ch

Post Reply