Transformation ASP No component upload class-upload

Source: Internet
Author: User
Tags count file size file upload include
Upload | No component transformation ASP no component upload class-Upload_5xsoft use manual 1.0

Tao dao old farmer http://www.5xsoft.com/[download]




Directory

1. About Upload_5xsoft

2. Operating platform and precautions

2. Members and objects of class

3. Using the example


About Upload_5xsoft




All along, due to the limitations of FileSystemObject, so the biggest problem of ASP is file upload, most of the solution is to install

Third-party upload component. There are many problems with third-party components, some components to register, and some components to add his copyright information to the form.

There is also the compatibility of components.

On the internet also circulated a lot of no component upload code, but can only upload text files, or only to upload files to the database.

I've been studying ASP for a while, and found that you can upload any type of file without Third-party components. Wrote this class, give everyone a

Convenient, the entire class is placed in a file: Upload_5xsoft.inc in the Example directory there is a complete file upload

Example program that can be used directly.

Affirm: The source code is completely open, may spread freely, but please retain its integrity, without the consent of the author, not for commercial.




Operating platform and precautions

A) can only run at Windows2000+iis 5, NT4+IIS4 or WIN98+PWS is not supported, as long as the ASP is added:
<!--#include file= "Upload_5xsoft.inc"--> on the line.


b When using file Upload, form form to add enctype= "Multipart/form-data" namely:

<form name= "Form1" method= "Post" action= "enctype=" Multipart/form-data ">
<input type= "text" value= "abc" name= "Text1" >
<input type=file name= "File" >
<input type=submit name= "Submit" value= "submitted" >
</form>




The object of the Upload_5xsoft

such as defining an uploaded object
<!--#include file= "Upload_5xsoft.inc"-->
<%
Set upload=new upload_5xsoft ' upload is an object
%>

Upload_5xsoft Object Members
File file object Set, (is a Dictionary object)

File Object Members:
Count property, number of file forms
filename attribute, the name of the uploaded file
FileSize property, the size of the uploaded file (0 indicates no file)
FilePath property, the path to the file before uploading
FormName property, name of file form
SaveAs method, store uploaded files, have a parameter, the path to the true path for example:
Example: Set File=upload.file ("File1") ' File1 for table Single-name

Response.Write "<br> filename:" &file. FileName

Response.Write "<br> File Size:" &file. FileSize

Response.Write "<br> file path:" &file. FilePath

File.saveas Server.MapPath ("/1.jpg")

Set file=nothing
Form form data set, (is a Dictionary object) to replace Request.Form
Count property, table singular
Exists method to check for the specified table Single-name
More use to see the Dictionary object in VBScript Help
Example:
' Get the data of the Text1 form, Uplaod is the object that you created first

Stext=upload.form ("Text1")
Version property, the Upload_5xsoft of the class, such as:

Response.Write Upload. Version




Using the sample

1. Upload an example of a JPG file:

File 1:upload.htm

<body>
<form name= "Form1" method= "Post" action= "upload.asp" enctype= "Multipart/form-data" >
<input type=file name= "File1" >
<input type=submit name= "Submit" value= "submitted" >
</form>
</body>

File 2:upload.asp

<body>
<!--#include file= "Upload_5xsoft.inc"-->
<%
Set Upload=new Upload_5xsoft
Set File=upload.file ("File1")
If File.filesize>0 Then
File.saveas Server.MapPath ("Temp.jpg")
Response.Write "<br> Upload file:" &file. filename& "=> temp.jpg ok!"
Response.Write "<br> File Size:" &file. FileSize
Set file=nothing
End If
Set upload=nothing
%></body>

2. List of file forms (multiple file uploads)
<body>
<!--#include file= "Upload_5xsoft.inc"-->
<%
Set Upload=new Upload_5xsoft
For each formName in Upload.file
Set File=upload.file (FormName)
If file. Filesize>0 Then
File. SaveAs Server.MapPath (file. FileName)
Response.Write file. Filepath&file. filename& "(" &file. filesize& ") =>"
Response.Write file. filename& "Success!<br>"
End If
Set file=nothing
Next
Set upload=nothing
%>


You may also use the upload program written by the author directly in the example directory.

Download Now

If there is a problem with the program, please write the author contact getc@163.com

The Old farmer of Tao Dao April 19, 2001



Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.