Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
11
Erster Beitrag:
vor 3 Jahren, 2 Monaten
Letzter Beitrag:
vor 3 Jahren, 2 Monaten
Beteiligte Autoren:
Gianni Spano, Fabrice Harari, Piet van Zanten, Allard, issah

[WB17] Storing images on a MySql db

Startbeitrag von Gianni Spano am 12.12.2014 21: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 ="\temp\tmpImage.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

Antworten:

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 ="\temp\tmpImage.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

von Fabrice Harari - am 12.12.2014 21:41
Hello Fabrice

Thank you for the hint.. :-)

Gianni

von Gianni Spano - am 13.12.2014 18:17
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

von Gianni Spano - am 13.12.2014 21:04
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

von Fabrice Harari - am 14.12.2014 12:03
Hi,

Have you considered not adding a path to a picture but adding the picture itself to the mysql db ?

Regards

Allard

von Allard - am 14.12.2014 14:35

Re: [WB17] Storing images on a MySql db *** SOLVED**

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

von Gianni Spano - am 14.12.2014 19:08
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

von issah - am 14.12.2014 21:32
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

von Gianni Spano - am 15.12.2014 14:13
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

von Piet van Zanten - am 16.12.2014 09:25
Hello Piet

Yes... it could be a solution to try...

I will check it..

Thanks for the help

Gianni

von Gianni Spano - am 16.12.2014 18:02
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.