Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2005, 06:30 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying binarydata as text

Hi guys,

i'm working on a project, and i'm kinda stuck.
i've got a SQL server to witch i upload binary data ( blobfield), using upload_files_without_com_v3 Created by Lewis Moten(very good code by the way!!!, you can get it at : http://www.Planet-Source-Code.com/vb...=8525&lngWId=4 )
working just fine for all files.
Client now want the following :
when he's upload a word document, he want to edit it in a webpage and the reinsert it into the blob field.

I've been trying to convert the binary data from the blob field to text, but i just can't seem to get readable text.

anybody any ideas???

thanks

Code:




<table width="50%" border="0" cellspacing="0" cellpadding="0">
<%
Set RSdocs = Con.execute("SELECT id,document_naam, project_id, klant_id FROM Tbl_docs ORDER by id ASC")
do while not RSdocs.eof 
%>
<tr><td>id=<a href="default.asp?id=<%=RSdocs("id")%>"><%=RSdocs("id")%></td><td><a href="default.asp?id=<%=RSdocs("id")%>">document_naam=<%=RSdocs("document_naam")%></td><td>project_id<%=RSdocs("project_id")%></td><td>klant_id=<%=RSdocs("klant_id")%></a></td></tr>
<%
rsdocs.movenext
loop
%>
<tr><td>id=<a href="default.asp?id=new">New</td><td><a href="default.asp?id=new">document_naam=Nieuwe upload</td><td>project_id=1</td><td>klant_id=1</a></td></tr>

</table>
<br><br>
<%




if Request.querystring("id") <> "" then
if Request.querystring("id") <> "new" then 
 id = Request.querystring("id")
else
 id = 5
end if  
Set RStest = Con.execute("select * From Tbl_docs where id =" & id)
if rstest("blobsize") <> "" then
 KBfilesize = Cint(RStest("blobsize") / 1024)
 MBfilesize = Cint(KBfilesize /1024)
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <form id="form1" name="form1" enctype="multipart/form-data" method="post" action="upload.asp?upload=yes&id=<%=Request.querystring("id")%>">
  <tr>
    <td width="100">document naam: </td>
    <td width="3">:</td>
    <td > <input name="klantnaam" type="text" value="<%=RStest("document_naam")%>" ></td>
  </tr>
  <tr>
    <td width="100">Project id: </td>
    <td width="3">:</td>
    <td><input name="projectnaam" type="text" value="<%=RStest("project_id")%>"></td>
  </tr>
  <tr>
    <td width="100">nieuw bestand: </td>
    <td width="3">:</td>
    <td><input name="file" type="file" size="30" /></td>
  </tr>
  <tr>
    <td width="100">bestands grootte </td>
    <td width="3">:</td>
    <td><%=KBfilesize%> KB of <%=MBfilesize%> MB</td>
  </tr>  
  <tr>
    <td width="100">&nbsp;</td>
    <td width="3">&nbsp;</td>
    <td><input type="submit"  value="Upload !" id=submit1 name=submit1></td>
  </tr>
  </form> 
</table>


<%
 blobcontenttype = RSTEST("blobContentType")
 if blobcontenttype = "image/bmp" or blobcontenttype = "image/gif" or blobcontenttype = "image/jpg" or blobcontenttype = "image/jpeg" or blobcontenttype = "image/pjpeg" then
  response.write(" <IMG SRC=""viewimage.ASP?id=" & Request.QueryString("id") & """>")
 else

Function BinaryToString(Binary)
   Dim cl1, cl2, cl3, pl1, pl2, pl3
  Dim L
  cl1 = 1
  cl2 = 1
  cl3 = 1
  L = LenB(Binary)

  Do While cl1<=L
    pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
    cl1 = cl1 + 1
    cl3 = cl3 + 1
    If cl3>300 Then
      pl2 = pl2 & pl3
      pl3 = ""
      cl3 = 1
      cl2 = cl2 + 1
      If cl2>200 Then
        pl1 = pl1 & pl2
        pl2 = ""
        cl2 = 1
      End If
    End If
  Loop
  BinaryToString = pl1 & pl2 & pl3
End Function



binarysource = rstest("blobdata")
textsource = BinaryToString(binarysource)
%>
<textarea name="<%=rstest("document_naam")%>">
<%
  With Response
    '.ContentType = "application/octet-stream"
    'rstest("blobContentType")
    '.AddHeader "Content-Disposition", "attachment; filename=" & rstest("document_naam")
    '.Charset = "UTF-8"
    .Write BinaryToString(rstest("blobdata"))
    '.Flush
    '.Write textsource
   End With
%>
</textarea>
<%
  end if

end if
%>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Text using CSS austinf CSS Cascading Style Sheets 3 October 11th, 2007 02:58 PM
Displaying text in textbox Europom Excel VBA 4 March 31st, 2007 06:28 AM
displaying variable in normal text yuvin ASP.NET 1.0 and 1.1 Basics 5 January 12th, 2007 02:03 AM
Displaying a text file in a web form. boksi ASP.NET 1.0 and 1.1 Basics 1 April 18th, 2005 10:54 AM
Displaying text depending on the value of a field lguzman Access VBA 1 May 30th, 2004 06:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.