Loading images to MySQL using Read/Write

Ken Ray kray at sonsothunder.com
Mon Feb 26 02:18:13 EST 2007


On Sun, 25 Feb 2007 22:28:00 -0800, Jim Schaubeck wrote:

> on mouseup
>   ask file "Select an Image file"
>   put it into tempvar
>   --
>   open file tempvar for binary read
>   read from file tempvar until end
>   put it into imagevar -- I'm hoping imagevar this would have the 
> data I need to store in MySQL
>   close file tempvar
>   --
>   open file "tempImageFile" for write

You need to use "binary write" here, I think... 

>   write imagevar to file "tempImageFile" at 1
>   close file "tempImageFile"
>   --
>   set the fileName of image "image1" to "tempImageFile"
> end mouseUp

Also, wouldn't it be easier to do:

on mouseUp
  ask file "Select an Image File"
  put it into tempVar
  if tempVar <> "" then
    put url ("binfile:" & tempVar) into imageVar
    -- then the test
    put imagevar into url ("binfile:tempImageFile")
    set the fileName of image "image1" to "tempImageFile"
  end if
end mouseUp


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



More information about the use-livecode mailing list