FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
WB21 Show Image from Mysql Database
WB21 Show Image from Mysql Database
Débuté par Julio Cesar, 12 mai 2017 04:28 - 4 réponses
Connectez-vous…
Julio Cesar
#1
Posté le 12 mai 2017 - 04:28
Hi
Im trying show images from a database in a image control but nothing is displayed.
Its a php Project.
Here is the code:
HReadSeekFirst(Chamados,ChamadosID,LOOP_CHAMADOS)
IF HFound(Chamados) THEN
FSTC_DESCRICAO = Chamados.Descricao
FSTC_SOLICITANTE = Chamados.Solicitante
EDT_RESPOSTA = Chamados.Resposta
RADIO_STATUS = Chamados.Status
IMG_ANEXO..Image = Chamados.Anexo1 <============
PopupDisplay(POPUP_CHAMADOS,popupCenter+popupFixed)
END
Signaler
0
0
Piet van Zanten
#2
Posté le 12 mai 2017 - 09:44
Hi Julio,
Did you set the image type correctly in the image control description?
Kind regards,
Piet
Signaler
0
0
Gianni Spano
#3
Posté le 12 mai 2017 - 11:27
Hi Julio
First, you need to set your field in the table as a longblob type.
Code to select the image and put it in the image control:
SelectedFile is string SelectedFile = fSelect("C:\Directories", "File.jpg", ... "Selezionare un file", ... "File JPG (*.jpg)" + TAB + "*.jpg" + CR + "Tutti" + TAB + "*.*", "jpg") nIdx is int=TAB_Fotografie IF SelectedFile <> "" THEN {"IMG_Image"+nIdx}=SelectedFile END
An example of saving pictures in a database:
j is int sPath is string sSql is string dsMyQuery is Data Source bRes is boolean sSql="DELETE FROM fotografie WHERE codice='"+magazzino.codice+"'" bRes=HExecuteSQLQuery(dsMyQuery,hQueryDefault,sSql) fotografie.codice=magazzino.codice FOR j=1 TO 5 sPath={"IMG_Image"+j} IF sPath <> "" THEN fotografie.riga=j HLinkMemo(fotografie,fotografia, sPath, hMemoImg) HAdd (fotografie) END END
Hope in this help
Gianni
Signaler
0
0
Gianni Spano
#4
Posté le 12 mai 2017 - 11:28
...continue
This is the portion of code to load the pictures from database:
sSql is string dsMyQuery is Data Source bRes is boolean bDati is boolean sPath is string nId is int sSql="SELECT * FROM fotografie WHERE codice='"+magazzino.codice+"'" bRes=HExecuteSQLQuery(dsMyQuery,hQueryDefault,sSql) IF bRes THEN bDati=HReadFirst(dsMyQuery) IF bDati THEN WHILE NOT HOut (dsMyQuery) nId=dsMyQuery.riga sPath=fExeDir()+"\Photo"+nId+".JPG" HExtractMemo(dsMyQuery,fotografia,sPath) {"IMG_Image"+nId}=sPath HReadNext () END END END
Signaler
0
0
ccc2
#5
Posté le 12 mai 2017 - 13:56
Hi Julio,
if you are not fans of HLinkMemo/HExtractMemo ,
another method is convert image/file to base64 before save . when retrieve make sure convert back to buffer.
IMG_ANEXO..Value = Uncrypt(Chamados.Anexo1,"",cryptNone,encodeBASE64)
if you want to view image from MysqlWorkBench
select FROM_BASE64(Chamados.Anexo1) as Anexo1 from Chamados
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte