View Full Version : Need assistance with ASP Upload form

10-05-2007, 05:11 AM
Hello! I am new to the code world... I was wondering if someone more experienced could look at my code and tell me what I am doing wrong. I keep getting an error, which I have provided near the bottom of this post. Any help is very much appreciated, and I am willing to accept any alternative scripts. All I have is MySQL with no tables set up, which is why I am using ASP. I am open to suggestions, but expect a lot of elementary questions if you are suggesting a different method!

Here is my ASP Code, named upload.asp.

Set Upload = Server.CreateObject("Persits.Upload.1")

' Upload files
Upload.OverwriteFiles = False ' Generate unique names
Upload.SetMaxSize 5000000 ' Truncate files above 1MB
Upload.Save "c:\uploads"

' Process all files received
For Each File in Upload.Files

' Save in the database as blob
File.ToDatabase "DSN=data;UID=sa;PWD=zzz;", _
"insert into mytable(blob) values(?)"

' Move to a different location
File.Copy "c:\archives" & File.ExtractFileName
' Display description field
Response.Write Upload.Form("Description") & "<BR>"

' Display all selected categories
For Each Item in Upload.Form
If Item.Name = "Category" Then
Response.Write Item.Value & "<BR>"
End If

And here is my HTML form code:

<form action="http://www.MYURLHASBEENREMOVED/upload.asp" method="post">
Please select a file to upload: <input type="FILE" name="FILE"></input><br />
<p><br />
Please enter you email address: <input type="TEXT" name="EMAIL"></input><br />
<p><br />
Please enter you case number: <input type="TEXT" name="DESCRIPTION"></input><br />
<p><br />
Please select file contents: <select> name=&quot;CATEGORY&quot; multiple=&quot;&quot;&gt;
<option>Site File
</option><option>Design File
</option><option>Zip File
</option></select><br />
<p><br />
<textarea rows="10" cols="50" wrap="physical" name="comments">
If this is a new issue, please enter a brief description.
<p><br />
<input type="SUBMIT" value="Upload File"></input>

I keep getting the following error when I attempt to test this upload on my server:

Method Not Allowed

The requested method POST is not allowed for the URL /upload.asp.

What file do I need to set permissions on? What should the permissions be? Have I formatted the code correctly?

I am hoping to find some way to auto notify the administrator whenever something is uploaded with a link to the upload, the email address and case number entered, the file type selected, as well as any comments placed in the text box.

Any ideas?

Thanks, ahead of time!