Important - When using this code, you must be sure to check the extention type that is being uploaded to the server. We do not allow scripts to be uploaded via asp upload pages. These include .php, .asp, .aspx, .cgi, .js, .vbs, .pl, .exe, or any other script file. Sites found allowing these upload types will be suspended until the proper checks are enabled.
Here is a FAQ for helping you with Persist ASPUpload on Flarehosting.com.
Please contact us to set the permissions on the folders you are planning on uploading the files to.
There are 3 files:
File 1, Select.htm : Source file selection
<HTML>
<BODY BGCOLOR="white">
<FORM METHOD="POST" ACTION="upload.asp" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><br>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
</BODY>
</HTML>
File 2, Upload.asp : call of the ASPUpload component
<%
Set Upload = Server.CreateObject("Persits.Upload")
' Limit file size to 50000 bytes, throw an exception if file is larger
Upload.SetMaxSize 50000, True
' Intercept all exceptions to display user-friendly error
On Error Resume Next
' Perform upload
Count =
Upload.Save "d:\sample_path\upload"
' 8 is the number of "File too large" exception
If Err.Number = 8 Then
Response.Write "Your file is too large. Please try again."
Else
If Err <> 0 Then
Response.Write "An error occurred: " & Err.Description
Else
Response.Write "Success!"
End If
End If
%>
Files:<BR>
<%
Response.Write Count & " file(s) uploaded to d:\sample_path\upload"
For Each File in Upload.Files
Response.Write File.Name & "= " & File.Path & " (" & File.Size &" bytes)<BR>"
Next
'It is very important to check for extensions that you do not want. It is not a safe pratice to allow asp, php and .net scripts to be upload.
For Each File in Upload.Files
Ext = UCase(Right(File.Path, 3))
'delete and files that DOES NOT end with .txt and .doc
If Ext <> "TXT" and Ext <> "DOC" Then
Response.Write "File " & File.Path & " is of invalid type."
File.Delete
End If
Next
%>
|