繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP应用 >> 不用组件实现上载功能(英文NT)2

不用组件实现上载功能(英文NT)2

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:6  文字大小:【】【】【
简介:'---- file name /handld_upload.asp <% Option Explicit %> <% Response.Expires=0 Response.Buffer = TRUE Response.Clear Const IMAGE_SIZE = "width=""200"" height=&q...

'---- file name /handld_upload.asp

<% 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") = ""

Response.Redirect goURL

%>

'---- file name /test.asp/

<% Option Explicit %>

<%

On Error Resume Next

Response.Expires = 0

Response.AddHeader "Pragma", "no-cache"

Dim thisFile

thisFile = Right(Request.ServerVariables("PATH_INFO"),Len(Request.ServerVariables("PATH_INFO"))-InStrRev(Request.ServerVariables("PATH_INFO"), "/"))

If Request("imageCancel") <> "" Then

Session("StoredFile") = ""

Session("strImage") = ""

End If

%>

Corp2Net.com

alink=<%= COLOR_AL_1 %> vlink=<%= COLOR_VL_1 %> bgcolor=<%= COLOR_BG_1 %>>

Only upload *.jpg or *.gif file!


Otherwise, image may not show correctly!

<% If ( Len(Session("strImage")) > 0 ) Then %>

<% Else %>

<% End If %>

>

<%= Session("strImage") %>

>

Upload / preview image:
Step 1: Prepare an image with 72 dpi resolution.
Step 2: Select your image file
Step 3: Press "Upload" button
Step 4: Continue OR repeat Step 1-3 to change the image

">



责任编辑:admin
相关文章