An application example of ASP non-component uploading class

Source: Internet
Author: User
Tags object end include rar save file
Upload | no component | application Example | upload | no component | application example

"'--------upload.htm-------------

<script language= "JavaScript" >
function Checkfile (myForm)
{
if (myform.file1.value== ') return false;
Myform.submit ();
}
</script>
<form method= "POST" name= "UPL" action= "fjupload.asp" enctype= "Multipart/form-data" >
<input type= "File" Name= "File1" id= "File1" >
<input type= "button" Name= "Upfiles" value= "Upload" >
</form>

"'------------fjupload.asp-----------------

<!--#include file= ". /.. /inc/config.asp "-->
<!--#include file= ". /.. /inc/upload.inc "-->
<%

Founderr=false
Savepath = Server.MapPath ("?????") ' Directory where uploaded files are stored


Call Upload_0 () ' Use transformation no component upload class

' Upload Program
Sub Upload_0 () ' Use transformation no component upload class

Set upload=new upload_file ' Build upload Object

Dim msg ' Stores error messages that occur during upload
Dim FileCount ' Total number of files stored
Dim Upcount ' Stores The total number of uploaded files
Filecount=0
Upcount=0
For every formName in Upload.file ' lists all uploaded files
Set File=upload.file (formName) ' generates a File object
if (file.filename<> "") Then
Founderr=false
Filecount=filecount +1
Set File=upload.file (formName) ' generates a File object

Randomize
Rannum=int (900*RND) +100
Last_fn=hour (now ()) & Minute (now ()) & Second (now ()) & Rannum ' generates a random number appended to the end of the file to prevent file name collisions
Ext_fn=file.fileext ' name extension

Filename=savepath & "\" & File.smallfilename & "_" & LAST_FN
If ext_fn<> "" Then Filename=filename & "." & EXT_FN

If FSO. FileExists (filename) Then
Msg=msg & "\ r \ n" & file.filename & "File already exists, please change file name"
Founderr=true
End If

' If you can upload it, do the upload
If Founderr<>true Then
File. SaveToFile filename ' Save file
if (err=0) then
Upcount = Upcount + 1
Msg=msg & "\ r \ n" & File.filename & "Upload success!" "
' If it is a RAR file for decompression
if (LCase (file.fileext) = "rar") Then
Call Uncompess (Filename,savepath) ' uncompressed
End If
Else
Msg=msg & "\ r \ n" & file.filename & "Upload failed!" "
End If
End If
End If
Set file=nothing
Next
Set fso=nothing
Set upload=nothing
' If the number of files uploaded successfully is less than the number of uploaded files, the error prompts
If



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.