Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is the dbf format to hold an image
Message
From
06/04/2017 07:34:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
01649850
Message ID:
01649863
Views:
96
>>>what is the dbf format to hold an image
>>
>>If you are using native VFP tables, then do not hold image within the table but just the path to image.
>
>But I am converting the file to htm and I want to send it to my client with the image in the htm

Having the image itself in the database (even if it is not native VFP) wouldn't help you in that case, and actually having separate is better.

In the html, you would have the image as a src attribute. i.e.:
<img src='blah blah.jpg'/>
src could be a relative path or a url. For example you might be serving the images from a web server, and you simply have the url address in your HTML. Otherwise send the images within the same folder and have their names as src. I think I have posted this sample code many times here and on foxite:
Public oForm
oForm = Createobject('form1')
oForm.Show()

Define Class form1 As Form
	Top = 0
	Left = 0
	Height = 480
	Width = 750
	Caption = "HTML sample"

	* This is IE control - you'd use webbrowser4 from gallery instead
	* just because it already has some checks, extra pem. ie: wouldn't need readystate part
	* for the sake of keeping code short here I directly use olecontrol itself
	Add Object htmlviewer As OleControl With ;
		Top = 0, ;
		Left = 0, ;
		Height = 400, ;
		Width = 750, ;
		OleClass = 'Shell.Explorer'

	Add Object text1 As TextBox With ;
		Height = 25, ;
		Left = 12, ;
		Top = 432, ;
		Width = 60, ;
		Name = "Text1"

	Add Object text2 As TextBox With ;
		Height = 23, ;
		Left = 84, ;
		Top = 432, ;
		Width = 300, ;
		Name = "Text2"

	Add Object text3 As TextBox With ;
		Height = 23, ;
		Left = 390, ;
		Top = 432, ;
		Width = 125, ;
		Name = "Text3"

	Add Object text4 As TextBox With ;
		Height = 23, ;
		Left = 520, ;
		Top = 432, ;
		Width = 125, ;
		Name = "Text4"

	Procedure Init
		Local lnPerrow, lnCurrent
		Create Cursor myImages (ImagePath m,FirstName c(12), LastName c(12))
		For ix=1 To Adir(arrImages,_samples+'data\graphics\*.gif')
			Insert Into myImages Values ;
				(_samples+'data\graphics\'+arrImages[m.ix,1],'FirstName'+Trans(ix),'LastName'+Trans(ix))
		Endfor

		*Now we have a test table - create HTML
		lnPerrow = 2 && How many would we show on a line
		lnCurrent = 0 && Do not use recno() thinking it might be ordered on an index

		Set Textmerge On
		Set Textmerge To Memvar lcHtml Noshow
		* Initialize lcHTML
		\<HTML><BODY><TABLE border='1'>
		Select myImages
		Scan
			lnCurrent = lnCurrent+1
			If (lnCurrent-1)%lnPerrow=0
				If lnCurrent>1
		\</TR>
				Endif
		\<TR>
			Endif
		\<TD><A href="<< trans(recno())>>_TEXT">
		\	<< JustStem(ImagePath)>></A></TD>
		\<TD><A href="<< trans(recno())>>">
		\    <img border="0" height="60" width="80" src="<< trim(chrtran(ImagePath,'\','/'))>>"></A></TD>

		Endscan
		\</TR>
		\</TABLE></BODY></HTML>
		Set Textmerge To
		Set Textmerge Off
		*!*	    Modify Command (this.HTMLFile) && If you ever wonder created HTML
		With Thisform.htmlviewer
			.Navigate2('about:blank')
			Do While .ReadyState # 4 && Wait for ready state
			Enddo
			.Document.Write( m.lcHtml )
		Endwith
	Endproc

	Procedure htmlviewer.BeforeNavigate2
		*** ActiveX Control Event ***
		Lparameters pdisp, url, Flags, targetframename, postdata, headers, Cancel
		Cancel = .T.  && do not navigate to anywhere
		With Thisform && with webbrowser4 also this.oHost is the form itself or container
			Local lcRecNo
			lcRecNo = Strtran(Lower(m.url),'about:','')
			.text1.Value = m.lcRecNo
			lnRecno = Strextract(m.lcRecNo,'','_TEXT',1,1+2)
			Go Val(m.lcRecNo) In 'myImages'
			If (Atc('_TEXT', m.lcRecNo) > 0)
				.text2.Value = 'TextCLICK'+myImages.ImagePath
			Else
				.text2.Value = myImages.ImagePath
			Endif
			.text3.Value = myImages.FirstName
			.text4.Value = myImages.LastName
		Endwith
	Endproc

Enddefine
PS: Sending a PDF might be a better option vs sending an HTML.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform