不用组件实现上载功能(2)
不用组件实现上载功能(2),不用组件实现上载功能(2)
<% Option Explicit %
<%
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
Const IMAGE_SIZE = "width=""200"" height=""150"""
Dim UploadRequest
Set UploadRequest = Server.CreateObject("Scripting.Dictionary")
Dim byteCount, RequestBin
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin
Dim saveURL, goURL, filepathname, value, filename
'---- save path
'saveURL = UploadRequest.Item("saveURL").Item("Value")
saveURL = "/"
'---- jump to file path when finish upload
goURL = UploadRequest.Item("goURL").Item("Value")
filepathname = UploadRequest.Item("my_file").Item("FilePathName")
value = UploadRequest.Item("my_file").Item("Value")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,""))
'---- debug
'Response.Write saveURL&"**"&goURL&"**"&filepathname
'Response.Write "**"&filename
'Response.End
Dim fso, MyFile, i
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(Server.mappath(saveURL) & "") Then
RecMkDir(Server.mappath(saveURL) & "")
End If
Set MyFile = fso.CreateTextFile(Server.mappath(saveURL) & "" & filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
Session("StoredFile") = filename
Session("strImage") = "<img src="http://img.jcwcn.com/attachment/portal"