Author |
Topic |
|
Krali
Starting Member
16 Posts |
Posted - 10 February 2004 : 11:05:24
|
Hello,
this ist the code in the upload script:
' --- CHECK FILE FOR ACCEPTABILITY --- extension = LCase(Mid(filename,InStrRev(filename,"."))) If _ extension <> ".asp" And _ extension <> ".aspx" And _ extension <> ".cgi" And _ extension <> ".pl" And _ extension <> ".php" And _ extension <> ".vbs" And _ extension <> ".vbx" And _ extension <> ".scr" And _ extension <> ".js" And _ extension <> ".com" And _ extension <> ".bat" And _ byteCount <= 50000000000000 _ Then
But if I want to upload a bigger file, then 3 MB, there comes a "Page cannot be shown - error" !!!
Does anybody has a help for me ?
Nice greetings
Klaus |
Edited by - ruirib on 10 February 2004 11:11:49 |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 10 February 2004 : 11:25:13
|
More than likely the connection with the server is timing out; can you turn off frindly HTTP error messages in IE and post the exact error message that is returned.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
laser
Advanced Member
Australia
3859 Posts |
Posted - 10 February 2004 : 14:56:06
|
I think you'll need FTP to upload a 3Mb file. Maybe on a good broadband connection you can upload a 3Mb file before the script times out, but you may not be that lucky. |
|
|
Krali
Starting Member
16 Posts |
Posted - 11 February 2004 : 04:51:36
|
Hello,
I don't think, that it is a connection problem, cause it was tried in the own network, we have a 100 MBit-Connection to the server.
And the error message is coming directly about 2 seconds after clicking on the upload-button, not after 90 seconds for example.
I will try to show you the exactly error message from IE.
Thx
Nice greetings
Klaus |
|
|
Krali
Starting Member
16 Posts |
Posted - 11 February 2004 : 05:20:02
|
This is the error message, after clicking the upload - button:
Microsoft VBScript runtime error '800a0005' Invalid procedure call or argument: 'MidB' /forum/upload.asp, line 4
And this is the code, I made no changes on my own:
<%Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function%>
Nice greetings
Klaus |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 11 February 2004 : 06:42:49
|
Does the file you're trying to upload have a space in it's name? Looks like that's what may be causing the problem, although I'm not 100% on that.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
Krali
Starting Member
16 Posts |
Posted - 11 February 2004 : 07:17:43
|
No, there is no space in the name.
Here is the code of the uploadfile.asp - File, which has the upload-form:
<!--#include file="upload.asp"-->
<%
SUBFOLDER = "Data"
Server.ScriptTimeout = 3600 ' 1 hour timeout
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
oldfilename = filename
filename = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now) & "_" & filename
' --- CHECK FILE FOR ACCEPTABILITY ---
extension = LCase(Mid(filename,InStrRev(filename,".")))
If _
extension <> ".asp" And _
extension <> ".aspx" And _
extension <> ".cgi" And _
extension <> ".pl" And _
extension <> ".php" And _
extension <> ".vbs" And _
extension <> ".vbx" And _
extension <> ".scr" And _
extension <> ".js" And _
extension <> ".com" And _
extension <> ".bat" And _
byteCount <= 50000000000000 _
Then
value = UploadRequest.Item("blob").Item("Value")
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd) & SUBFOLDER & "\" & filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
If byteCount < 1000 Then
strFileSize = Round(byteCount,2) & " Bytes"
ElseIf strFileSize < 1000000 Then
strFileSize = Round(byteCount/1000,2) & " KB"
Else
strFileSize = Round(byteCount/1000000,2) & " MB"
End If
%>
<html>
<head>
<title></title>
<script>
window.opener.PostTopic.Message.value=window.opener.PostTopic.Message.value + "\n\nAnhang: [url=\"<%= SUBFOLDER & "/" & filename %>\"]<%= oldfilename %>[/url] <%= strFileSize %>";
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#FFFFFF" style="font-family: Arial; font-size: 10pt;" onUnLoad="window.opener.focus();">
<p align="center">
<h4><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Die Datei wurde
hochgeladen</font></h4>
<hr size="1" noshade>
<table>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> Dateiname </b></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <%= oldfilename %> </font></td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> Typ </b></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <%= extension %> </font></td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> Grösse </b></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <%= strFileSize %> </font></td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> Link </b></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <a href="<%= SUBFOLDER & "/" & filename %>"><%= SUBFOLDER & "/" & filename %></a> </font></td>
</tr>
</table>
<hr size="1" noshade>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Tip: </b> Der Link
zur Datei befindet sich am Ende ihrer Nachricht.</font>
</body>
</html>
<% Else %>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/theme.css">
</head>
<body bgcolor="#F0E8C0">
<p align="center">
<h4><font color="red">Die Datei konnte nicht hochgeladen werden.</font></h4><hr>
<table>
<tr><td><b> Dateiname </b></td><td> <%= oldfilename %> </td></tr>
<tr><td><b> Typ </b></td><td> <%= extension %> </td><td><font color="red">Dieses Datei Format ist nicht erlaubt</font></td></tr>
<tr><td><b> Grösse </b></td><td> <%= Round(byteCount/1000,2) %> KB </td><td><font color="red">Die Datei darf nur eine bestimmte grösse haben</font></td></tr>
</table><hr>
<a href="#" onClick="window.close();">Fenster schiessen.</a>
</p>
</body>
</html>
<%
End If
Server.ScriptTimeout = 90 ' default timeout
%>
|
|
|
|
Topic |
|
|
|