Solution for simultaneous uploading of multiple files in ASP

Source: Internet
Author: User
Tags ftp connection ftp login
Solution for simultaneous uploading of multiple files in ASP

The upload form is as follows:

Title:
Gender:MaleFemale
Belong:
LiteratureSportsArtOthers
Selected or not:
Content: Category:
Category 1Category 2Category 3Category 4Category 5

Select File 1:
Select File 2:
Select File 3:
Select File 4:
Select File 5:

 

ASP source code:

<HTML>
<Body>
<Title> File Upload </title>
<Center>
</Center>
<% Set OBJ = server. Createobject ("yousoft. uploadfile ")
Response. write "Total uploads" & obj. count & "files <br> total data size" & obj. totalbytes & "bytes <br> total time spent" & (obj. spendtime/1000) & "seconds <br>"
Response. Write obj. Version %>
<HR>
<Table width = "75%" border = "1">
<Tr>
<TD width = "20%"> title: </TD>
<TD width = "80%"> <% = obj. Form ("title1") %> </TD>
</Tr>
<Tr>
<Td width = "20%"> Yes </td>
<Td width = "80%"> <% = obj. form ("sel1") %> </td>
</Tr>
<Tr>
<Td width = "20%"> Gender: </td>
<Td width = "80%"> <% = obj. form ("sex1") %> </td>
</Tr>
<Tr>
<Td width = "20%"> category: </td>
<Td width = "80%"> <% = obj. form ("list1") %> </td>
</Tr>
<Tr>
<Td width = "20%"> content: </td>
<Td width = "80%"> <% = obj. form ("Content1") %> </td>
</Tr>
<Tr>
<TD width = "20%"> selected? </TD>
<TD width = "80%"> <% = obj. Form ("select1") %> </TD>
</Tr>
<Tr>
<TD width = "20%"> submit button: </TD>
<TD width = "80%"> <% = obj. Form ("save") %> </TD>
</Tr>
</Table>
<P> & nbsp; </P>
<P> upload the file as follows: <br>
</P>
<Table border = "1">
<Tr>
<TD nowrap> name </TD>
<TD nowrap> file name (including the extension) </TD>
<TD nowrap> file name (excluding the extension) </TD>
<TD nowrap> file size (B) </TD>
<TD nowrap> original file path </TD>
<TD nowrap> file extension </TD>
<TD nowrap> original file name (including path) </TD>
</Tr>
<% For I = 0 to OBJ. Count-1%>
<% Userfile = obj. userfile (I) %>
<Tr>
<TD>
<% = Userfile %>
</TD>
<TD>
<% = Obj. filename (userfile) %>
</TD>
<TD>
<% = Obj. filenamex (userfile) %>
</TD>
<TD>
<% = Obj. FileSize (userFile) %>
</Td>
<Td>
<% = Obj. FilePath (userFile) %>
</Td>
<Td>
<% = Obj. FileExt (userFile) %>
</Td>
<Td>
<% = Obj. OldFileName (userFile) %>
</Td>
</Tr>
<% 'Obj. SaveToFTP "192.168.7.168", 21,5000, "xu", "xu", 0, "", 0, "", userFile, Obj. FileName (userFile) %>
<% 'Obj. SaveFile userFile, "c:/" & Obj. FileName (userFile) %>
<% 'Obj. savefileas userfile, "C:/" & obj. filename (userfile) %>
<% 'Obj. savefileas "file6", "C:/a.txt" %>
<% '= Obj. getfiledata (userfile, "TXT") %>
<% Next
Set OBJ = nothing %>
</Table>
<HR>
</Body>
</Html>

Upload result:

Upload 5 files in total
Total data size: 4317 bytes
Total time spent. 321 seconds
Youupload 1.0 copyright (c) XU Changyou

Title: Solution for simultaneous uploading of multiple files in ASP
Belong: Sports Art
Gender: Male
Category: Category 3
Content: In most J2EE systems, we want factories or managers in the form of stateless session beans to trigger appropriate events. However, when creating a bean instance in an EJB container, a set of repeated listeners are displayed. This article shows you how to correctly implement the "Observer" mode in the EJB environment.
Selected or not: Yes
Submit button: Confirm upload

Upload the file as follows:

Name File name (including extension) File Name (excluding the extension) File size (B) Original file path File Extension Original file name (including path)
File1 AUTOEXEC. BAT AUTOEXEC 2 C :/ . BAT C:/AUTOEXEC. BAT
File2 Boot. ini Boot 199 C :/ . Ini C:/boot. ini
File3 CONFIG. SYS CONFIG 2 C :/ . SYS C:/CONFIG. SYS
File4 Skin.txt Skin 2236 C :/ . Txt C:/skin.txt
File5 WINNTnwstatus.txt WINNTnwstatus 59 C :/ . Txt C:/WINNTnwstatus.txt

The above uses the youupload upload component. The following describes youupload:

YouUpload -- File Upload Component

Welcome to YouUpload!

License Agreement

See license.txt.

Features

  • Supports uploading multiple files
  • All formats of file upload, zip, JPG, and GIF are supported.
  • Supports renaming and saving uploaded files
  • Other form inputs can be used to carry additional information, for example, file description.
  • Supports determining the size and type of uploaded files
  • Supports SAVING file content to the database
  • Supports uploading to the FTP directory
  • You do not need to set the directory to write in IIS (if it is an NTFS file system, its security needs to be set, you can simply set it to everyone full control, or set it to iusr_server full control)
  • Youupload is free of charge and has no function restrictions.
  • Applicable System

    Applicable to Windows 98 + pws4, NT4.0 SERVER + IIS 4, Win2k + IIS 5

    Http://www.csdn.net

    Installation Guide

    Requirements: Windows NT Server 4 edition + SP3 + ie4.01 + Option Pack/WIN98 + ie4.01

    1. If you download the installer, run Setup.
    2. Test. Copy examples in the installation directory to the release directory of the Web server to test the default document default. asp.
    3. Enter 'HTTP: // yourhost/uploadtest/'in the address bar of the browser /'
    4. If there is copyright ownership on the top of the page, it will be okay.
    5. upload some files and try again.

    Component Properties

    • Object. Form (FieldName)
      Return form data

      Object. Form ("title") 'title is the Form name

    • Object. SaveFile (FieldName, FileName)
      FieldName: form name
      FileName: New File Name (Note: path should be included)

      Dim upl, FileName
      Set upl = Server. CreateObject ("yousoft. YouUpload ")
      FileName = upl. FileName ("File1 ")
      Upl. SaveFile "File1", "c:/temp/" & FileName

    • Object. savefileas (fieldname, fname)
      Fieldname: form name
      Filename: New File Name (Note: path should be included)

      Dim UPL, filename
      Set upl = server. Createobject ("yousoft. youupload ")
      Filename = upl. filename ("file1 ")
      Upl. savefileas "file1", "C:/temp/" & filename

    • Object. savetoftp (ftp_host, ftp_port, timeout, ftp_user, ftp_password,
      Use_proxy, proxy_host, proxy_port, user_dir, fieldname, filename)
      Ftp_host: ftp host (preferably IP address)
      Ftp_port: FTP server port (usually 21)
      Timeout: FTP connection timeout
      Ftp_user: FTP login name
      Ftp_password: ftp logon Password
      Use_proxy: whether to use a proxy server to connect to FTP. If it is set to 1, use proxy = 0 instead of proxy.
      Proxy_host: proxy server host (preferably IP), used in combination with use_proxy
      Proxy_port: proxy server port, used in combination with use_proxy
      User_dir: Specifies the current FTP path. If it is null, no path is specified, that is, the default path after logon.
      Fieldname: form name, from which to save the file
      FileName: Specifies the new file name.

      Obj. SaveToFtp "192.168.7.168", 21,5000, "xu", "xu", 0, "", 0, "", "file1", "new.exe"

    • Object. FileName (FieldName)

    • Get the file name (including the extension)

    • Object. FilePath (FieldName)
      Obtain the path of the uploaded file

    • Object. FileSize (FieldName)
      Get the size of the uploaded file

    • Object. FileExt (FieldName)
      Get the Upload File Extension

    • Object. OldFileName (FieldName)
      Obtain the complete name of the uploaded file (including the path)

    • Object. FileNameX (FieldName)
      Get the file name (excluding the extension)

    • Object. Count
      Number of uploaded files

    • Object. TotalBytes
      Total Bytes of uploaded data

    • Object. SpendTime
      Upload time (unit: milliseconds)

    • Object. userFile (N)
      Obtain the nth name (form name) of the uploaded file)

    • Object. GetFileData (FieldName, DataType)
      Obtain uploaded file data
      DataType:
      "Bin" retrieves binary data
      "Txt" to retrieve text data

      You can obtain data and store it in the database in text or binary format.

      <% = Obj. GetFileData ("File1", "txt") %>

    • Object. Version
      Obtain the current YouUpload version

     

    Instructions for use

    See examples in the examples directory

    Writing form upload
    <Form enctype = "multipart/form-Data" method = "Post" Action = "Upload. asp" name = "Upload">
    Enctype = "multipart/form-Data" is required, and the method must be post

    If you obtain the number of files uploaded
    Set OBJ = server. Createobject ("yousoft. uploadfile ")
    Response. Write "file count:" & obj. Count

    If multiple files are uploaded
    OBJ. userfile (N)
    Obtain the nth name (form name) of the uploaded file)

    How to get the file suffix
    EXT = fileext (fieldname) 'fieldname is the form name, for example, 'file1'

    How to save the file content to the database
    If you use SQL Server, You need to define an image field
    Dim Conn, RS
    Set conn = server. Createobject ("ADODB. Connection ")
    Conn. Open "testfile", "sa", "XXX"
    Set rs = server. Createobject ("ADODB. recordset ")
    Rs. Open "select * From where filename is null", Conn, 1, 3
    Rs. addnew
    RS ("FILENAME") = obj. filename ('file1 ')
    RS ("filesize") = obj. filesize ('file1 ')
    RS ("filecontent"). AppendChunk obj. getfiledata (userfile, "bin") 'blob data cannot be directly assigned values. If it is not binary, save "bin" to "TXT"
    Rs. Update
    Rs. Close
    Conn. Close
    Set rs = nothing
    Set conn = nothing
    On the contrary, to extract data from the database, please refer to the following program
    Dim Conn, RS
    Dim content
    Set conn = server. CreateObject ("adodb. connection ")
    Conn. open "testfile", "sa", "xxx"
    Set rs = server. CreateObject ("adodb. recordset ")
    Rs. Open "SELECT * FROM where id =" & id, conn, 1, 1
    Content = rs ("filecontent"). getChunk (clng (rs ("filesize ")))))
    Conn. Close
    Set rs = nothing
    Set conn = nothing

    Possible Installation Problems

    If you find out, please contact me!

    Problems with program usage

    If you find out, please contact me!

    Test feedback

    If you find any problem in the test, please mailto: yousoft@chinaren.com? Subject = about YouUpload, or please discuss or leave a message on the bbs on my homepage.

    I hope you will have more comments on this component.

    When we discuss asp, we often encounter many problems that can only be solved by using asp components, and these com can only be found on foreign sites, it can be seen that there are still few such aspects in China. So I hope you can get your support.

    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.