如何将二进制字符串转为一般字符串

czh918 2000-05-22 10:15:00
我在编一个FORM向ASP服务器发送图片和图片说明,我用RESPONSE.BINARYREAD读取下来,存入数据库的图片字段和图片说明字段,请问我如何将图片说明字段分离出来?
...全文
169 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xqzz 2000-05-23
  • 打赏
  • 举报
回复
怎么题目和里面的内容不一样啊,如果仅仅是将二进制转换成普通的字符串,那么这样就可以了:
dim ss as string
dim dd() as byte
dim bb() as byte
'然后dd里面读入十六进制数据
'那么
ss=strConv(dd,Unicode)
那么ss就是有dd转换成的特殊的字符串了
如果要转换回去
那么
bb=strConv(ss,vbFormUnicode)
这样bb就是和dd一模一样的二进制数据了
huitor 2000-05-23
  • 打赏
  • 举报
回复
请使用cpshost.dll
具体使用方法如下:
<%@ Language=VBScript %>
<%
Option Explicit

Dim strServerURL 'Local Web Server Name including http:// protocol
Dim strTargetURL 'Directory where we will upload our file to
Dim strRepostURL 'Path to the page we will display after our file uploads
Dim strPathToPA 'Path to the cpshost.dll
Dim strPostingURL 'Action path for our form

If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If



In the next section we use ASP Server Variables to retrieve the name of our Web server, which will make this code portable.

strServerURL = "http://" + Request.ServerVariables("SERVER_NAME")
strTargetURL = strServerURL & "/Administration"
strRepostURL = strServerURL & "/Administration/AddEmployeeFinish.asp"
strPathToPA = strServerURL & "/Scripts/cpshost.dll"
strPostingURL = strPathToPA + "?PUBLISH?" + strRepostURL
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>


The final step is to display our form. We set the enctype of the form to multipart/form-data and dynamically populate the values for the action tag and target URL.

<form enctype="multipart/form-data" action="<% = strPostingURL %>" method="POST">
<input type="hidden" name="TargetURL" value="<% = strTargetURL %>">
<center><table>
<tr>
<td align="left">Supply the local path to the previously scanned image file in *.gif, *.jpeg format:</td>
</tr>
<tr>
<td align="left"><input name="my_file" type="file" size="20"></td>
</tr>
<tr>
<td align="right"><input type="Submit" value="Next >>"></td>
</tr>
<table></center>
</form>

</BODY>
</HTML>


When this page is loaded the user will be able to browse their local file system to find the photograph that they need to upload. When they click on the Next button, the form will be posted to the CPSHOST.DLL for upload processing. Once that has completed successfully, our AddEmployeeFinish.asp page will be displayed in the user's browser. As you can see, there really isn't much to this.

We will create a new ASP page called called AddEmployeeFinish.ASP. This will be our confirmation page, and it will display after the file has been uploaded. In this first section we once again force authentication on the page and define our variables. Copy the following code to your ASP file:

Option Explicit
Dim strFilename 'File uploaded to web server
Dim strPath 'Path up file uploaded to web server
Dim I 'Counter
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If


Working with a multipart form is a little different than working with a standard form. We need to iterate through the form collection to retrieve the filename, file extension, and physical path. We do this in the following section of code, assigning these values to our variables.

For I = 1 To Request.Form("FileName").Count
strFilename = Request.Form("FileName")(I) & Request.Form("FileExtention")(I)
strPath = Request.Form("FilePath")(I)
Next
%>

Finally, we display a confirmation message to the user:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Response.Write(strPath & strFilename & " was uploaded sucessfully")
%>
</BODY>
</HTML>

czh918 2000-05-22
  • 打赏
  • 举报
回复
同时在同一表单中上传就没有更好的方法吗?谢谢!
kxy 2000-05-22
  • 打赏
  • 举报
回复
传送时候就分开传不就行了。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧