At 02:30 PM 7/8/99 -0500, you wrote:
> Still having problems getting the ASP MySql image import/export to
>work...if you still have the patience for this I would certainly appreciate
>your looking at the following code (my boss is about to kill me):
>--------- code starts -----------
>Set Objfilesys = Server.CreateObject("Scripting.FileSystemObject")
>Set ipfile = Objfilesys.OpenTextfile("c:\inetpub\wwwroot\admin\tne4.gif")
>giftext = mysqlstringconvert(ipfile.readall)
>rem At this point the variable giftext should contain the gif
>(mysqlstringconvert is a function to escape chr(0) rem and quotes and double
>rem If I then:
>Set Connection = Server.CreateObject("ADODB.Connection")
>Set RS = Server.CreateObject("ADODB.Recordset")
>Connection.Execute("insert gifdb set gifid='gif52', gif='" + giftext + "'" )
>Set rs = Connection.Execute("select * from gifdb where gifid = 'gif52'")
>response.contenttype = "image/GIF"
>------------ code ends ----------------------
>I get a broken image.....any thoughts/suggestions/help would be appreciated.
Don't escape a binary image using the text style escape sequences. Bad
Use this instead for your insert statement.....
Connection.Execute("insert gifdb set gifid='gif52', gif=0x" +
Where, in VB I use.....
Private Function ProcessHex(D As Variant) As String
Dim Buffer() As Byte
Dim PH As String
Dim Count As Long
Buffer = D
PH = String(UBound(Buffer) + 1, "0")
For Count = LBound(Buffer) To UBound(Buffer) Step 2
Mid(PH, Count + 1, 2) = Right("0" & Hex(Buffer(Count)), 2)
ProcessHex = PH
This passes the gif to the MySql server in a way that none of the data gets
corrupted by translation loss. This is what I use, it works very well. It
should be easy to convert the above routine into script.
I have a question though... Why not just use the dll's created by DBWiz? It
takes care of all that for you.....
Let me know how it works out.....
Peter B. Carter (peterc@stripped)
Flames are a waste of cyberspace, don't bother.......
|• Re: import image files||Peter Carter||9 Jul|