Current location: Hot Scripts Forums » Programming Languages » ASP » please read and help me!


please read and help me!

Reply
  #1 (permalink)  
Old 07-26-03, 11:50 PM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Angry please read and help me!

Hi, im having trouble with setting up a upload/download system on my test site. The script is made so all files in a certain folder will be shown on the download.asp page. The command is
" folder = "cgi-bin" "(the outer quotes arent in the command). It comes up with this error:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'folder'

/download.asp, line 23

Can someone tell me how to define this or something???
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.
Reply With Quote
  #2 (permalink)  
Old 07-27-03, 12:39 PM
angst angst is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
post all the code for the download.asp script
Reply With Quote
  #3 (permalink)  
Old 07-27-03, 01:28 PM
ldnconsulting ldnconsulting is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Did you DIM the folder Variable?

Dim myFolder

myFolder="../cgi-bin/"

FSO.create "myFolder/" & <%nuewuser%>" & "/"
Reply With Quote
  #4 (permalink)  
Old 07-27-03, 02:01 PM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
download script

<%

folder = "databases"

If Left(server.mappath("."),1) = "/" Then
strslash = "/"
Else
strslash = "\"
End If
servername = Request.Servervariables("server_name")
scriptpath = Request.Servervariables("script_name")
scriptpath = Mid(scriptpath,(Instrrev(scriptpath, "/")),1)
Dim filesobj, fileslist, fname, posnumright
dim f, dflm
Set filesobj = Server.CreateObject("scripting.filesystemobject")
Set fileslist = filesobj.GetFolder(server.mappath(".") & "/" & folder)
%>
<!-- ************* Table start and header row ****************-->
<table width="95%">
<tr>
<td width="50%">File</td><td>Date</td><td>Size</td></tr>

<%
For each thing In fileslist.files
posnumright = instrrev(thing, strslash)
fname = right(thing,(len(thing)-posnumright))
Set f = filesobj.GetFile(thing)
fdlm = f.datelastmodified
If f.size > 1023 Then
fsize = CStr(CInt(f.size / 1024)) & "K"
Else
fsize = CStr(f.size) & " bytes"
End If
physicalpath = server.mappath(".")
%>
<tr>
<td>
<!-- ******* First column with link to file name ******* -->
<a href="http://<%=servername & scriptpath & folder & "/" & Server.HTMLEncode(fname) %>" target="_blank"><%=Server.HTMLEncode(fname)%></a>
</td>
<td>
<!-- ******* Second column with last modified date of file ***** -->
<%=Server.HTMLEncode(fdlm)%>
</td>
<td>
<!-- ******* Third column with file size ******** -->
<%= Server.HTMLEncode(fsize) %>
</td>
</tr>
<%
Set f = Nothing
Next
Set fileslist = Nothing
Set filesobj = Nothing
%>
<!-- *************** End of Table ****************** -->
</table>
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.
Reply With Quote
  #5 (permalink)  
Old 07-27-03, 05:16 PM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
ERROR

hey ,ldnconsulting, i tried to DIM it like u said, but it came up with this error:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/download.asp, line 26

FSO.create "myFolder/" & <%nueuser
-------------------------^

So, i just posted the script up. Please read it and tell me whats wrong.
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.
Reply With Quote
  #6 (permalink)  
Old 07-27-03, 07:24 PM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Change that line to..

Code:
FSO.create "myFolder/" & nueuser
Since you are already between the <% %> tags, you need not include another <% tag.
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL

Last edited by Shane; 07-28-03 at 12:30 AM.
Reply With Quote
  #7 (permalink)  
Old 07-27-03, 09:42 PM
ldnconsulting ldnconsulting is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah Shane nailed it on the head! Sorry should have specified that it was mock code not in correct syntax.
Reply With Quote
  #8 (permalink)  
Old 07-27-03, 09:49 PM
ldnconsulting ldnconsulting is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Also to DIM it you only needed to add


Dim Folder


This tells the script to expect some value to be stored in the variable named folder. Since you had not done that then tried to use folder, it didnt know what it was for.
Reply With Quote
  #9 (permalink)  
Old 07-28-03, 12:50 AM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
ok thanks a lot guys.
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.
Reply With Quote
  #10 (permalink)  
Old 07-28-03, 02:15 AM
Arctic Arctic is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: BC, Canada
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
hey again, i need some help again. I have an upload script and was wondering how i could put a limit on the file size so people cant upload like 20mb programs. and also a limit on file types, like only .exe and .zip!

Here is the script:
(There are 2 files)
1) saveupload.asp

<!--#INCLUDE FILE="upload.class"-->
<%
Dim oUpload
Dim oFile
Dim sFileName
Dim oFSO
Dim sPath
Dim sNewData
Dim nLength
Dim bytBinaryData


Const nForReading = 1
Const nForWriting = 2
Const nForAppending = 8

' grab the uploaded file data
Set oUpload = New clsUpload
Set oFile = oUpload("File1")

' parse the file name
sFileName = oFile.FileName
If Not InStr(sFileName, "\") = 0 Then
sFileName = Mid(sFileName, InStrRev(sFileName, "\") + 1)
End If

' Convert the binary data to Ascii
bytBinaryData = oFile.BinaryData
nLength = LenB(bytBinaryData)
For nIndex = 1 To nLength
sNewData = sNewData & Chr(AscB(MidB(bytBinaryData, nIndex, 1)))
Next

' Save the file to the file system
sPath = Server.MapPath("../files") & "\"
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
oFSO.OpenTextFile(sPath & sFileName, nForWriting, True).Write sNewData
Set oFSO = Nothing

Set oFile = Nothing
Set oUpload = Nothing
%>
<html>
<head><title>FilesDomain.net - Upload</title>
<link rel=stylesheet type="text/css" href="../style.css">
<script src="../noclick.js" type="text/javascript"></script>
</head>
<body background="../main_bg.jpg">
<div align="center">
<img src="upload_complete.gif">
<br>
<!-- AD -->
<!--#include virtual="adrotator/adrotator_468x60.asp" -->
<!-- AD -->
<br>
Your file has been saved on the server. Click here to view this file:<BR><BR>
<A href="files/<%=sFileName%>">files/<%=sFileName%></A>
<br>
<!-- AD -->
<!--#include virtual="adrotator/adrotator_468x60.asp" -->
<!-- AD -->
<!--#include virtual="footer.asp" -->
</div>
</body>
</html>

2) upload.class

<%
' ------------------------------------------------------------------------------
' Container of Field Properties
Class clsField
Public FileName
Public ContentType
Public Value
Public FieldName
Public Length
Public BinaryData
End Class
' ------------------------------------------------------------------------------
Class clsUpload
' ------------------------------------------------------------------------------
Private nFieldCount
Private oFields()

' ------------------------------------------------------------------------------
Public Property Get Count()
Count = nFieldCount
End Property
' ------------------------------------------------------------------------------
Public Default Property Get Field(ByRef asFieldName)
Dim lnLength
Dim lnIndex

lnLength = UBound(oFields)

If IsNumeric(asFieldName) Then
If lnLength >= asFieldName And asFieldName > -1 Then
Set Field = oFields(asFieldName)
Else
Set Field = New clsField
End If
Else
For lnIndex = 0 To lnLength
If LCase(oFields(lnIndex).FieldName) = LCase(asFieldName) Then
Set Field = oFields(lnIndex)
Exit Property
End If
Next
Set Field = New clsField
End If
End Property
' ------------------------------------------------------------------------------
Public Function Exists(ByRef avKeyIndex)
Exists = Not IndexOf(avKeyIndex) = -1
End Function
' ------------------------------------------------------------------------------
Public Property Get ValueOf(ByRef avKeyIndex)
Dim lnIndex
lnIndex = IndexOf(avKeyIndex)
if lnIndex = -1 Then Exit Property
ValueOf = oFields(lnIndex).Value
End Property
' ------------------------------------------------------------------------------
Public Property Get FileNameOf(ByRef avKeyIndex)
Dim lnIndex
lnIndex = IndexOf(avKeyIndex)
if lnIndex = -1 Then Exit Property
FileNameOf = oFields(lnIndex).FileName
End Property
' ------------------------------------------------------------------------------
Public Property Get LengthOf(ByRef avKeyIndex)
Dim lnIndex
lnIndex = IndexOf(avKeyIndex)
if lnIndex = -1 Then Exit Property
LengthOf = oFields(lnIndex).LengthOf
End Property
' ------------------------------------------------------------------------------
Public Property Get BinaryDataOf(ByRef avKeyIndex)
Dim lnIndex
lnIndex = IndexOf(avKeyIndex)
if lnIndex = -1 Then Exit Property
BinaryDataOf = oFields(lnIndex).BinaryData
End Property
' ------------------------------------------------------------------------------
Private Function IndexOf(ByVal avKeyIndex)
Dim lnIndex
If IsNumeric(asFieldName) Then
avKeyIndex = CLng(avKeyIndex)
If nFieldCount > avKeyIndex And avKeyIndex > -1 Then
IndexOf = avKeyIndex
Else
IndexOf = -1
End If
Else
For lnIndex = 0 To nFieldCount - 1
If LCase(oFields(lnIndex).FieldName) = LCase(avKeyIndex) Then
IndexOf = lnIndex
Exit Function
End If
Next
IndexOf = -1
End If
End Function
' ------------------------------------------------------------------------------
Public Property Get ContentTypeOf(ByRef avKeyIndex)
Dim lnIndex
lnIndex = IndexOf(avKeyIndex)
if lnIndex = -1 Then Exit Property
ContentTypeOf = oFields(lnIndex).ContentType
End Property
' ------------------------------------------------------------------------------
Private Sub Class_Terminate()
For lnIndex = 0 To nFieldCount - 1
Set oFields(0) = Nothing
Next
End Sub
' ------------------------------------------------------------------------------
Private Sub Class_Initialize()

Dim lnBytes ' Bytes received from the client
Dim lnByteCount ' Number of bytes received
Dim lnStartPosition ' Position at which content begins
Dim lnEndPosition ' Position at which content ends

Dim loDic ' Contains properties of each
' specific field
' Local dictionary object(s)
' to be appended to class-scope
' dictioary object.

Dim lnBoundaryBytes ' Bytes contained within the current boundary
Dim lnBoundaryStart ' Position at wich the current boundary begins
' within the lnBytes binary data.
Dim lnBoundaryEnd ' Position at wich the current boundary ends
' within the lnBytes binary data.
Dim lnDispositionPosition

Dim lsFieldName ' Name of the current field being parsed from
' Binary Data
Dim lsFileName ' Name of the file within the current boundary
Dim lnFileNamePosition ' Location of file name within current boundary

' Initialize Fields
nFieldCount = 0
ReDim oFields(-1)

' Read the bytes (binary data) into memory
lnByteCount = Request.TotalBytes
lnBytes = Request.BinaryRead(lnByteCount)

'Get the lnBoundaryBytes
lnStartPosition = 1
lnEndPosition = InstrB(lnStartPosition, lnBytes, CStrB(vbCr))

lnBoundaryBytes = MidB(lnBytes, lnStartPosition, lnEndPosition - lnStartPosition)

lnBoundaryStart = InstrB(1, lnBytes, lnBoundaryBytes)


' Loop until the BoundaryBytes begin with "--"
Do Until (lnBoundaryStart = InstrB(lnBytes, lnBoundaryBytes & CStrB("--")))

' All data within this boundary is stored within a local dictionary
' to be appended to the class-scope dictionary.

ReDim Preserve oFields(nFieldCount)
nFieldCount = nFieldCount + 1

Set loField = New clsField

lnDispositionPosition = InstrB(lnBoundaryStart, lnBytes, CStrB("Content-Disposition"))

' Get an object name
lnStartPosition = InstrB(lnDispositionPosition, lnBytes, CStrB("name=")) + 6
lnEndPosition = InstrB(lnStartPosition, lnBytes, CStrB(""""))
lsFieldName = CStrU(MidB(lnBytes, lnStartPosition, lnEndPosition - lnStartPosition))
loField.FieldName = lsFieldName

' Get the location fo the file name.
lnFileNamePosition = InstrB(lnBoundaryStart, lnBytes, CStrB("filename="))
lnBoundaryEnd = InstrB(lnEndPosition, lnBytes, lnBoundaryBytes)

'Test if object is a file
If Not lnFileNamePosition = 0 And lnFileNamePosition < lnBoundaryEnd Then

' Parse Filename
lnStartPosition = lnFileNamePosition + 10
lnEndPosition = InstrB(lnStartPosition, lnBytes, CStrB(""""))
lsFileName = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
loField.FileName = lsFileName

' Parse Content-Type
lnStartPosition = InstrB(lnEndPosition,lnBytes,CStrB("Content-Type:")) + 14
lnEndPosition = InstrB(lnStartPosition,lnBytes,CStrB(vbCr))
ContentType = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
loField.ContentType = ContentType

' Parse Content
lnStartPosition = lnEndPosition + 4
lnEndPosition = InstrB(lnStartPosition,lnBytes,lnBoundaryBytes)-2
Value = MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition)
loField.BinaryData = Value & CStrB(vbNull)
loField.Length = LenB(Value)
Else

' Parse Content
lnStartPosition = InstrB(lnDispositionPosition, lnBytes, CStrB(vbCr)) + 4
lnEndPosition = InstrB(lnStartPosition, lnBytes, lnBoundaryBytes) - 2
Value = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
loField.Value = Value
loField.Length = Len(Value)
End If

Set oFields(UBound(oFields)) = loField

'Loop to next object
lnBoundaryStart = InstrB(lnBoundaryStart + LenB(lnBoundaryBytes), lnBytes, lnBoundaryBytes)

Set loField = Nothing

Loop

End Sub
' ------------------------------------------------------------------------------
Private Function CStrU(ByRef psByteString)
Dim lnLength
Dim lnPosition
lnLength = LenB(psByteString)
For lnPosition = 1 To lnLength
CStrU = CStrU & Chr(AscB(MidB(psByteString, lnPosition, 1)))
Next
End Function
' ------------------------------------------------------------------------------
Private Function CStrB(ByRef psUnicodeString)
Dim lnLength
Dim lnPosition
lnLength = Len(psUnicodeString)
For lnPosition = 1 To lnLength
CStrB = CStrB & ChrB(AscB(Mid(psUnicodeString, lnPosition, 1)))
Next
End Function
' ------------------------------------------------------------------------------
End Class
' ------------------------------------------------------------------------------
%>
__________________
http://www.streamsearch.ca - Live stream search engine. Find radio stations to listen to and TV channels to watch!

http://www.machonemedia.ca - Mach One Media web development and media services.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed finding the right script Sniper12p Script Requests 0 10-05-03 03:31 PM
Help with ASP! Arctic The Lounge 1 08-12-03 03:21 PM
Help me to pint the table kevin PHP 5 07-05-03 03:27 AM


All times are GMT -5. The time now is 02:59 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.