Upload video using asp

Source: Internet
Author: User

Simple Application to the Beijing official site to download compressed files, which contains examples
However, here I re-edited the component-less upload and added the following content:

1. Supports uploading images, audio, video, compression, and other types of files (you can customize restricted format files)

2. classify folders of different types of files (create folders by file type and create subfolders by year-month)

3. the uploaded file name does not use a sequential number (this is not good for search), and a random number is also added.

4. Descriptions of functional programs are also provided. For details, refer to the file content.

Declaration: since it is an upload task, it generally requires the support of the relevant Upload components, while the non-component upload class is the no-component upload class of the old rice fragrant farmer, which is widely used on the network. The current version is V2.0, the file content is as follows. Copy the code and save it as upload. inc

 

<Script RUNAT = server language = VBscript>
Dim Data_5xsoft

Class upload_5xsoft
  
Dim objForm, objFile, Version

Public function Form (strForm)
  StrForm = lcase (strForm)
  If not objForm. exists (strForm) then
    Form = ""
  Else
    Form = objForm (strForm)
  End if
End function

Public function File (strFile)
  StrFile = lcase (strFile)
  If not objFile. exists (strFile) then
    Set File = new FileInfo
  Else
    Set File = objFile (strFile)
  End if
End function

Private Sub Class_Initialize
  Dim RequestData, sStart, vbCrlf, sInfo, iInfoStart, iInfoEnd, tStream, iStart, theFile
  Dim iFileSize, sFilePath, sFileType, sFormvalue, sFileName
  Dim iFindStart, iFindEnd
  Dim iFormStart, iFormEnd, sFormName
  Version = "Environment HTTP upload program Version 2.0"
  Set objForm = Server. CreateObject ("scripting. Dictionary ")
  Set objFile = Server. CreateObject ("scripting. Dictionary ")
  If Request. TotalBytes <1 then Exit Sub
  Set tStream = Server. CreateObject ("adodb. stream ")
  Set Data_5xsoft = Server. CreateObject ("adodb. stream ")
  Data_5xsoft.Type = 1
  Data_5xsoft.Mode = 3
  Data_5xsoft.Open
  Data_5xsoft.Write Request. BinaryRead (Request. TotalBytes)
  Data_5xsoft.Position = 0
  RequestData = Data_5xsoft.Read

  IFormStart = 1
  IFormEnd = LenB (RequestData)
  VbCrlf = chrB (13) & chrB (10)
  SStart = MidB (RequestData, 1, Region B (iFormStart, RequestData, vbCrlf)-1)
  IStart = LenB (sStart)
  IFormStart = iFormStart + iStart + 1
  While (iFormStart + 10) <iFormEnd
    IInfoEnd = InStrB (iFormStart, RequestData, vbCrlf & vbCrlf) + 3
    TStream. Type = 1
    TStream. Mode = 3
    TStream. Open
    Data_5xsoft.Position = iFormStart
    Data_5xsoft.CopyTo tStream, iInfoEnd-iFormStart
    TStream. Position = 0
    TStream. Type = 2
    TStream. Charset = "gb2312"
    SInfo = tStream. ReadText
    TStream. Close
    'Get the form project name
    IFormStart = required B (iInfoEnd, RequestData, sStart)
    IFindStart = InStr (22, sInfo, "name =", 1) + 6
    IFindEnd = InStr (iFindStart, sInfo, ", 1)
    SFormName = lcase (Mid (sinfo, iFindStart, iFindEnd-iFindStart ))
    'If it is a file
    If InStr (45, sInfo, "filename =", 1)> 0 then
        Set theFile = new FileInfo
        'Get the file name
        IFindStart = InStr (iFindEnd, sInfo, "filename =", 1) + 10
        IFindEnd = InStr (iFindStart, sInfo, ", 1)
        SFileName = Mid (sinfo, iFindStart, iFindEnd-iFindStart)
        TheFile. FileName = getFileName (sFileName)
        TheFile. FilePath = getFilePath (sFileName)
        'Get file type
        IFindStart = InStr (iFindEnd, sInfo, "Content-Type:", 1) + 14
        IFindEnd = InStr (iFindStart, sInfo, vbCr)
        TheFile. FileType = Mid (sinfo, iFindStart, iFindEnd-iFindStart)
        TheFile. FileStart = iInfoEnd
        TheFile. FileSize = iFormStart-iInfoEnd-3
        TheFile. FormName = sFormName
        If not objFile. Exists (sFormName) then
          ObjFile. add sFormName, theFile
        End if
    Else
    'For a Form Project
        TStream. Type = 1
       

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.