I just downloaded some freeware code to allow me to add a web page to a site in order to give certain users the ability to upload files to a web site that I administer for them. The site is for a non-profit and is hosted on my home network The code was downloaded from BOLTWARE and is attached and listed below (.asp and .inc files). Since I have no experience with ASP programming, I'm at a loss as to how to troubleshoot the error 500 that the browser is thowing when I attempt to view the page in the browser.
The sample code provided by the vendor was installed pretty much as they suggest, with the exception that I placed the asp and inc files in a secured (NTFS and SSL) folder one level below the root of the site:
\Members_ONLY - secured folder
\Members_ONLY\uploads - base upload folder
\Members_ONLY\uploads\temp - scratch folder
\Members_ONLY\uploads\data - file upload destination folder
I think the problem could be related to how to set the code to point to the correct folders. I removed the extraneous code for writing to a database since it's not needed at this point.
All the folders under \Members_ONLY have their NTFS permissions set fairly liberally until this issue is resolved; then they will be locked down further.
O/S: W2K3 Standard w/SP1 and fully patched.
Server Hardware: Intel Motherboard, 1GB RAM, 10/100 integrated NIC, Adaptec 3400S 4-channel RAID w/26 drives in 3 RAID 5 arrays using various drive sizes - 9.1GB, 18.2GB and 36.4GB, Adaptec 2410SA cabinet w/4 190GB SATA drives in RAID 5 array used for virtual tape backup. Standard floppy, CDRW drive, Serial/Parallel and USB ports, 4 Compaq Proliant Storage System U/1 towers. Most hardware except m-board and SATA RAID cabinet salvaged from the "graveyard" at work.
I'm an ASP novice and plan on learning more about ASP programming...the last real programming I did was in '86 assembler back in the 1980's and it came easy since I was working in a hardware development lab and understood things at the machine code level.
Any help geting this to work would be greatly appreciated, since I made a commitment (mostly to keep me from getting e-mails with attachments to place into the site) to get this app up and running by the weekend (shoulda' known better...)
.
Thanks,
Jon
Example Code:
file_server.asp:
<!-- #include file="file_upload.inc" --><%
Dim Form, FSO, File
Set Form = Server.CreateObject("cASPer.FileUpload")
Form.ProcessRequest DataPath, False
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Select Case Form("Op")
'----------------------------------------------------------------
Case "Delete" 'Default action: list all files and display form
FSO.DeleteFile DataPath & "\" & Form("File")
End Select
%><H1>Upload a File</H1>
<FORM METHOD="POST" ENCTYPE="multipart/form-data"
ACTION="file_server.asp">
<INPUT TYPE="FILE" NAME="File_1">
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
<H1>File List:</H1>
<TABLE BORDER="1">
<TR><TH>Action</TH><TH>Filename</TH></TR>
<%
For Each File In FSO.GetFolder(DataPath).Files
%> <TR><TD><A HREF="file_server.asp?Op=Delete&File=<%
Write Server.URLEncode(File.Name)
%>">Delete</A></TD><TD><A HREF="data/<%
Write File.Name
%>"><%= ToHtml(File.Name) %></A></TD></TR>
<%
Next
%></TABLE>
<P><B>About this Component:</B>
<BR><%= ToHtml(Form.About) %>
****************************
file_upload.inc:
<%
Option Explicit
Dim TempPath, DataPath, DbConnection
'We'll be storing data in the "data" subfolder of the folder
'our sample programs are in; likewise for "temp"
DataPath = Split(Request.ServerVariables("PATH_TRANSLATED"), "\")
ReDim Preserve DataPath(UBound(DataPath) - 1)
TempPath = Join(DataPath, "\") & "\temp"
DataPath = Join(DataPath, "\") & "\data"
Set DbConnection = Server.CreateObject("ADODB.Connection")
DbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DataPath & "\..\Sample.mdb"
DbConnection.Open
'Shorthand for Response.Write
Function Write(Text)
Response.Write Text
End Function
'Convert the text into an HTML-friendly version
Function ToHtml(ByVal Text)
Dim Pos
Text = "" & Text
Text = Replace(Text, "&", "&")
Text = Replace(Text, ">", ">")
Text = Replace(Text, "<", "<")
Text = Replace(Text, """", """)
Text = Replace(Text, vbCrLf, vbCrLf & "<BR>")
ToHtml = Text
End Function
'Open a recordset
Function OpenWriteRecordset(Sql)
Set OpenWriteRecordset = Server.CreateObject("ADODB.Recordset")
OpenWriteRecordset.CursorType = 2
OpenWriteRecordset.CursorLocation = 2
OpenWriteRecordset.LockType = 3
OpenWriteRecordset.Open Sql, DbConnection
End Function
%>
The sample code provided by the vendor was installed pretty much as they suggest, with the exception that I placed the asp and inc files in a secured (NTFS and SSL) folder one level below the root of the site:
\Members_ONLY - secured folder
\Members_ONLY\uploads - base upload folder
\Members_ONLY\uploads\temp - scratch folder
\Members_ONLY\uploads\data - file upload destination folder
I think the problem could be related to how to set the code to point to the correct folders. I removed the extraneous code for writing to a database since it's not needed at this point.
All the folders under \Members_ONLY have their NTFS permissions set fairly liberally until this issue is resolved; then they will be locked down further.
O/S: W2K3 Standard w/SP1 and fully patched.
Server Hardware: Intel Motherboard, 1GB RAM, 10/100 integrated NIC, Adaptec 3400S 4-channel RAID w/26 drives in 3 RAID 5 arrays using various drive sizes - 9.1GB, 18.2GB and 36.4GB, Adaptec 2410SA cabinet w/4 190GB SATA drives in RAID 5 array used for virtual tape backup. Standard floppy, CDRW drive, Serial/Parallel and USB ports, 4 Compaq Proliant Storage System U/1 towers. Most hardware except m-board and SATA RAID cabinet salvaged from the "graveyard" at work.
I'm an ASP novice and plan on learning more about ASP programming...the last real programming I did was in '86 assembler back in the 1980's and it came easy since I was working in a hardware development lab and understood things at the machine code level.
Any help geting this to work would be greatly appreciated, since I made a commitment (mostly to keep me from getting e-mails with attachments to place into the site) to get this app up and running by the weekend (shoulda' known better...)
Thanks,
Jon
Example Code:
file_server.asp:
<!-- #include file="file_upload.inc" --><%
Dim Form, FSO, File
Set Form = Server.CreateObject("cASPer.FileUpload")
Form.ProcessRequest DataPath, False
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Select Case Form("Op")
'----------------------------------------------------------------
Case "Delete" 'Default action: list all files and display form
FSO.DeleteFile DataPath & "\" & Form("File")
End Select
%><H1>Upload a File</H1>
<FORM METHOD="POST" ENCTYPE="multipart/form-data"
ACTION="file_server.asp">
<INPUT TYPE="FILE" NAME="File_1">
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
<H1>File List:</H1>
<TABLE BORDER="1">
<TR><TH>Action</TH><TH>Filename</TH></TR>
<%
For Each File In FSO.GetFolder(DataPath).Files
%> <TR><TD><A HREF="file_server.asp?Op=Delete&File=<%
Write Server.URLEncode(File.Name)
%>">Delete</A></TD><TD><A HREF="data/<%
Write File.Name
%>"><%= ToHtml(File.Name) %></A></TD></TR>
<%
Next
%></TABLE>
<P><B>About this Component:</B>
<BR><%= ToHtml(Form.About) %>
****************************
file_upload.inc:
<%
Option Explicit
Dim TempPath, DataPath, DbConnection
'We'll be storing data in the "data" subfolder of the folder
'our sample programs are in; likewise for "temp"
DataPath = Split(Request.ServerVariables("PATH_TRANSLATED"), "\")
ReDim Preserve DataPath(UBound(DataPath) - 1)
TempPath = Join(DataPath, "\") & "\temp"
DataPath = Join(DataPath, "\") & "\data"
Set DbConnection = Server.CreateObject("ADODB.Connection")
DbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DataPath & "\..\Sample.mdb"
DbConnection.Open
'Shorthand for Response.Write
Function Write(Text)
Response.Write Text
End Function
'Convert the text into an HTML-friendly version
Function ToHtml(ByVal Text)
Dim Pos
Text = "" & Text
Text = Replace(Text, "&", "&")
Text = Replace(Text, ">", ">")
Text = Replace(Text, "<", "<")
Text = Replace(Text, """", """)
Text = Replace(Text, vbCrLf, vbCrLf & "<BR>")
ToHtml = Text
End Function
'Open a recordset
Function OpenWriteRecordset(Sql)
Set OpenWriteRecordset = Server.CreateObject("ADODB.Recordset")
OpenWriteRecordset.CursorType = 2
OpenWriteRecordset.CursorLocation = 2
OpenWriteRecordset.LockType = 3
OpenWriteRecordset.Open Sql, DbConnection
End Function
%>