 |
|
|
 |
 |
|
ทำได้ครับ ผมใช้ Persit Upload
filename.asp
<!-- AspUpload Code samples: filename.asp -->
<!-- Using memory uploads to access the file name -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<h3>Using memory uploads to access the file name</h3>
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="filename_upload.asp">
<%
Dim intCounter
intCounter = 1
Do While(intCounter < 11)
%>
Up file no.<%=intCounter%>
<% if intCounter<10 then response.write " " end if %>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE<%=intCounter%>"><BR>
<%
intCounter = intCounter+1
loop
%>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>
filename_upload.asp
<!-- AspUpload Code samples: filename_upload.asp -->
<!-- Invoked by filename.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<HTML>
<BODY>
<%
function getFileExt(fileName)
getFileExt = Mid(fileName, InstrRev(fileName, ".") + 1)
end function
Set Upload = Server.CreateObject("Persits.Upload")
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 100000, False
' Save to memory. Path parameter is omitted
Upload.Save
' Check whether a file was selected
Dim ExtArray(3) 'Fixed size array
ExtArray(0) = "jpg"
ExtArray(1) = "gif"
ExtArray(2) = "png"
ExtArray(3) = "jpeg"
Dim intCounter, FileSize, todays, upped
upped = 0
intCounter = 1
Do While(intCounter < 11)
todays = now()
todays = replace(todays, "/","")
todays = replace(todays, ":","")
todays = replace(todays, " ","-")
Set File = Upload.Files("FILE"&intCounter)
If Not File Is Nothing Then
' Obtain file name
Filename = File.Filename
Ext = getFileExt(Filename)
intSizeK = Int((File.Size/1024) + .5)
'GetFileSizeType = "("&UCase(File.GetExtensionName(File))&", "&intSizeK&"K)"
Response.Write(Filename &" Size : "& intSizeK & "K <br>" )
'Response.Write "extension : " & Ext &"<br>"
'For Each Ext In ExtArray
'Response.Write("."&Ext & " Recomment File type<br />")
'Next
For x=0 to Ubound(ExtArray)
if Ext = ExtArray(x) Then
'Response.Write("."&Ext & " Recomment File type<br />")
else
'Response.Write("."&Ext & " Un-Recomment File type<br />")
exit for
End if
Next
'check if file exists in c:\upload under this name
If Upload.FileExists("c:\upload\" & filename ) Then
Response.Write "File with this name already exists."
Else
' otherwise save file
File.SaveAs "c:\upload\"&todays&File.Filename
'Response.Write "File saved as " & File.Path & "<br>"
'Response.Write "<br>"&todays
upped = upped+1
End If
Else ' file not selected
'Response.Write "File not selected."
End If
intCounter = intCounter+1
loop
Response.Write(upped & " files uploaded")
Response.Write("<meta http-equiv='refresh' content='3; URL=filename.asp'>")
%>
</BODY>
</HTML>
|
 |
 |
 |
 |
Date :
12 มิ.ย. 2551 11:47:32 |
By :
trans |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|