Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
jwtea
- Posts: 66
- Joined: Fri Mar 23, 2018 2:01 am
Post
by jwtea » Sat Dec 01, 2018 6:03 pm
Hello , i got trouble uploading image to my sqldatabase ; my column for the image in the database will longblob.
Anybody got any idea on this issue?
I uses this code below to select a image
Code: Select all
on mouseup
put "*.jpg;*.gif;*.png" into types
if there is not an image "photo" then
create image "photo"
end if
answer file "Select file" with type types
if it is empty then exit mouseUp
put it into fn
if there is a file fn then
set the fileName of image "photo" to fn
end mouseup
-
Klaus
- Posts: 14193
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sat Dec 01, 2018 7:22 pm
Hi jwtea,
something like this should do:
Code: Select all
on mouseup
## type is a reserved word!
put "*.jpg;*.gif;*.png" into tTypes
if there is not an image "photo" then
create image "photo"
end if
answer file "Select file" with type tTypes
if it is empty then
exit mouseUp
end if
put it into fn
##if there is a file fn then
## User HAS in fact selected a file! ;-)
set the fileName of image "photo" to fn
## end if
## put binary image data into variable
put url("binfile:" & fn) into MyImageVar
revExecuteSQL Your_DB_ID_here, "insert into YourTable(YourLargeBlobDBField) values(:1)", "*bMyImageVar"
## the *b before the variable name indicates that you are passing binary data to the db.
## if the result...
## errorchecking here...
end mouseup
Best
Klaus
-
jwtea
- Posts: 66
- Joined: Fri Mar 23, 2018 2:01 am
Post
by jwtea » Sat Dec 01, 2018 7:57 pm
Hello Klaus ,
Thanks for your reply!
Actually i want to update the database instead of inserting, any idea how?
-
Klaus
- Posts: 14193
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Dec 02, 2018 3:24 am
-
Mikey
- VIP Livecode Opensource Backer

- Posts: 755
- Joined: Fri Jun 27, 2008 9:00 pm
Post
by Mikey » Sun Dec 02, 2018 4:31 pm
@jwtea
Just curious, whatcha cookin' with this project?
-
jwtea
- Posts: 66
- Joined: Fri Mar 23, 2018 2:01 am
Post
by jwtea » Tue Dec 04, 2018 7:39 pm
Mikey wrote: ↑Sun Dec 02, 2018 4:31 pm
@jwtea
Just curious, whatcha cookin' with this project?
Hahahah i'm actually just trying out the function not cooking anything yet
