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"> </td>
<td width="3"> </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
%>