|
| [WB17] Storing images on a MySql db |
| Iniciado por guest, 12,dic. 2014 22:07 - 10 respuestas |
| |
| | | |
|
| |
| Publicado el 12,diciembre 2014 - 22:07 |
Hello
I'm developing a little application (A test for children in pre-school age) My page contains 4 image and i have 45 records stored in the database that contains the 4 images for each test (image1, image2, image3, image4).
The image storing has not been a problem.
Instead, my problem is when a record is loaded and when i try to load the images from the database, the images don't appear.
My code:
sImageTempPath is string ="\ emp\ mpImage.png"
//Reading the record Hreadseek (tfl, id, gntest) // gntest contains the test number with the images if hfound (tfl) then hExtractMemo (tfl, image1, sImageTempPath) Page.Image1=sImageTempPath end
The code seems to be correct, but i'm not able to see the image in the control.
I have a similar project developed in Windev 17, and using the "dLoadImage" function, i'm able to see and navigate thru the various records reading the 4 images for each record read. I thought Webdev was working the same way,
Is there some friend who can help me to solve this problem (i think it is a stupid problem)?
Thank in advance.
Gianni |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,diciembre 2014 - 22:41 |
Hi Gianni
in webdev, you ahve to be extra careful as to WHERE you try to do something on disk...
So this
sImageTempPath is string ="\ emp\ mpImage.png"
is probably your problem...
As a rule, you should always work in a SUBdirectory of your website (ie use frepweb in your path)
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 13,diciembre 2014 - 19:17 |
Hello Fabrice
Thank you for the hint.. <img src="/NG2013_WEB/ui/smiley/1.gif" align=absmiddle border=0 alt=":-)">
Gianni |
| |
| |
| | | |
|
| | |
| |
| Publicado el 13,diciembre 2014 - 22:04 |
Hello Fabrice
Following your suggestion, now i have stored all the images in the pathname returned by the fWinDir () function, so the image pathname should be: (now i'm in development mode, not yet deployed)
sImagepathname is string="c:\My Sites\ASL_NEUROINF_WEB\Images"+"\"
This pathname is completed adding the name of the image, like: "c:\My Sites\ASL_NEUROINF_WEB\Images\Image01-1.png" (reading the image name from the db and adding to its full pathname as
sImagepathname+=tfl.image1 (tfl is the table from the db and image1 is a field that contains the image name.
Once i try to "load" the image on the "Clickable image control" (there are 4 equal controls, one for each image i want to show), the image doesn't appear. Here is the code:
IMG_IMAGE1=dloadImage(sImagePathname)
Why??? What i'm doing wrong???
Thanks for any help
Gianni |
| |
| |
| | | |
|
| | |
| |
| Publicado el 14,diciembre 2014 - 13:03 |
Hi Gianni
1. dloadimage is normally used to load an image into an image VARIABLE, not into a field. Normally, the syntax for an image field is simply MyImageFIeld=MyImageFullPath
2. You are on the web, which means that code may or may not "work" depending on WHERE it is called. So please tell us where is your code (page init, button, type of button, etc), and the type of web site/page you are working on
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 14,diciembre 2014 - 15:35 |
Hi,
Have you considered not adding a path to a picture but adding the picture itself to the mysql db ?
Regards
Allard |
| |
| |
| | | |
|
| | |
| |
| Publicado el 14,diciembre 2014 - 20:08 |
Hello to all
I have applied this code:
sImagePath is string sImagePath=fwebdir()+"\"+tfl.image1 (the name of the image stored in the _WEB project directory and read from the database (only the image name not the entire picture from blob field) and it works. then with a:
IMG_IMAGE1..image=sImagePath, now i'm able to see the images. and navigate loading every 4 images for each test.
Of course, i have stored all the images in the _WEB directory.
Thanks for your help,
Gianni |
| |
| |
| | | |
|
| | |
| |
| Publicado el 14,diciembre 2014 - 22:32 |
Why don't you just link the image field to the database....after all, they are already in the database which is why you the "hExtractMemo "
issah |
| |
| |
| | | |
|
| | |
| |
| Publicado el 15,diciembre 2014 - 15:13 |
Hi Issah
The images are only 45 files...I think it is more easy to store them on the WEB directory and i can easily load them...
Thanks..
Gianni |
| |
| |
| | | |
|
| | |
| |
| Publicado el 16,diciembre 2014 - 10:25 |
Hi Gianni,
It may seem fine to use less efficient technique as long as it works, but in the long run it will work against you. Using a direct link of an image control and FiletoPage as Issah suggested does not require any management by programming of files on disk. If you take the time to try it now, you will benefit by being able to build more efficient programs in the future.
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 16,diciembre 2014 - 19:02 |
Hello Piet
Yes... it could be a solution to try...
I will check it..
Thanks for the help
Gianni |
| |
| |
| | | |
|
| | | | |
| | |
|