True no component graphics and text mixed upload, powerful, no database, support Chinese!

Source: Internet
Author: User
Tags mixed
Inspired by some posts in this forum, the program was written. The program supports the uploading of any text and binary format files; Support file form field and common form field mixed upload, support Chinese filename, support overwriting upload and file with same name, automatically modify filename, support upload multiple files simultaneously, and multiple file form domain name can be the same; Support upload file size control ... I feel good about myself. Yo:


This program does not need any database support, directly upload the file saved to the server specified path.


test Environment: Windows2000 + IIS 5.0 (required for ADO version)


known bugs: Using the same file table Single-name to upload multiple files at the same time with a unique file name, and there are multiple identical file names on the server, only the first file will be renamed automatically uploaded successfully, and then the program error.


source code is as follows, you are welcome to refer to:


FileName: uploadx.asp


<%


Dim FormData, formsize, divider, Bcrlf


formsize = Request.TotalBytes


FormData = Request.BinaryRead (formsize)


Bcrlf = ChrB (+) & ChrB (10)


divider = LeftB (FormData, InStrB (FormData, Bcrlf)-1)


' Saves the uploaded file under the directory specified by path.


' FormField upload the form's "file" domain name


' Path The absolute path of the server to save the file in the form of "D:pathsubpath" or "D:pathsubpath"


' MaxSize limit the maximum length of uploaded files, kbyte as the unit


' Savtype the way the server saves files:


' 0 Unique file name method, if has the same name automatically renamed;


' 1 Method of error, if have the same name is an error;


' 2 Overlay method, if has the same name to overwrite the original file


Function savefile (Formfilefield, Path, MaxSize, Savtype)


Dim streamobj,streamobj1


Set streamobj = Server.CreateObject ("ADODB. Stream ")


Set StreamObj1 = Server.CreateObject ("ADODB. Stream ")


Streamobj.mode = 3


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.