<%@language=vbscript%> <% dim Uploader, File, Name, Items 'Get reference to ASPUploader: set Uploader = GetASPUploader 'ID is needed for progress bar only: Uploader.ID = Request.QueryString("ID") 'To restrict file types (file extensions) that users can upload, uncomment and edit this list: 'Uploader.ValidFileTypes = "txt,doc,rtf,pdf,htm,xml,jpg,bmp,gif,ico,png,swf,wav,mp3,wma,mid,avi,mpg,asf,wmv,zip,rar,ace,arj" 'Limit total upload size: Uploader.MaxTotalBytes = 2000000000 'By default, if uploaded file already exists in Destination, a number is appended to the name of new file. 'In order to overwrite existing files having the same name as the uploaded files, uncomment this: 'Uploader.Overwrite = true 'By default, ASPUploader automatically deletes incomplete files of unsuccessful (or canceled) uploads. 'If you do not want ASPUploader to delete such incomplete files, uncomment this: 'Uploader.DeleteIncomplete = false 'Set longer timeout for large files if needed: Server.ScriptTimeout = 900 'You can upload files directly to their destination folder. But it is a good practice to use a 'temporary folder for files being uploaded and then move completed files to their final destination. 'This way ensures the final destination will never contain incomplete files even if you shutdown 'your web server during upload or if electric power outage occurs. 'Use either physical (C:\Temp), relative (..\Temp), or virtual (/Temp) paths: Uploader.Destination = server.mappath("/invimages") 'If user cancels upload or attempts to upload files of invalid (unallowed) type or size, ASPUploader will 'raise an exception (error) with relevant descrition. Enable error handling to catch and handle such errors: on error resume next 'Start receiving and saving file(s): Uploader.Upload 'Check for error: if Err then Response.Write Err.Source & ": " & Err.Description Response.End end if 'The upload is successful (not canceled and no errors), if Err.Number = 0. 'Move all uploaded files to their final destination: for each File in Uploader.Files.Items File.Move "Upload\" 'Note: Path separator "\" means that "Upload\" is folder (not file) where to move the file (see manual). next 'Instead of moving all files to single destination, you could move each file to its own (different) 'destination, if needed. For example, to move the first file to folder "C:\Special", uncomment this: 'if Uploader.Files.Exists("File1") then Uploader.Files("File1").Move "C:\Special\" 'Note: "File1" is the input name of field that we have used in the html form for the first file. 'You can move a file and at the same time change its name with a single call to Move method. For example, to 'move the second file to folder "C:\Special" and change its filename to "User_DateTime.zip", uncomment this: 'if Uploader.Files.Exists("File2") then Uploader.Files("File2").Move "C:\Special\User_DateTime.zip" 'Note: You can use Copy method the same way. Also, Delete and Rename methods are available (see manual). 'Read properties of each uploaded file: Response.Write "You uploaded " & Uploader.Files.Count & " file(s) to folder Upload" & "
" for each File in Uploader.Files.Items Response.Write "Filename: " & File.Name & "
" Response.Write "Size: " & File.Size & " bytes
" Response.Write "Content type: " & File.ContentType & "
" Response.Write "Client path: " & File.ClientPath & "

" next 'Read values of each field of html form: Response.Write "You submitted the following form fields:
" for each Name in Uploader.Form Response.Write Name & ": " & Uploader.Form(Name) & "
" next Response.Write "
" Response.Write "Accessing individual files and form fields (see source code):
" 'Access uploaded files individually by either input name or index: if Uploader.Files.Exists("File1") then Response.Write "Name of File1 is " & Uploader.Files("File1").Name & "
" 'access by input name ("File1") Items = Uploader.Files.Items Response.Write "Size of the first file is " & Items(0).Size & " byte
" 'access by index (0 is index of the first file) end if 'Access values of form fields individually by either input name or index: Response.Write "Value of Text1 field is " & Uploader.Form("Text1") & "
" 'access by input name ("Text1") Items = Uploader.Form.Items Response.Write "Value of the second field is " & Items(1) 'access by index (1 is index of the second field) 'Check for errors: if Err then Response.Clear Response.Write Err.Source & ": " & Err.Description end if %>