ciao a tutti ho un problemino.... vorrei impostare il limite di byte in un upload ... questo è il file per upload
<%
Response.Buffer = True
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Conferma Upload</TITLE>
</HEAD>
<body bgcolor="#ffffff" text="#000000">
<%
byteCount = "1500000"
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,"\"))
value = UploadRequest.Item("blob").Item("Value")
c = UploadRequest.Item("c").Item("Value")
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_I NFO")))-30
'************************************************* ***************
'il -14 presuppone che tutti e 3 i file siano nella root
'se per esmpio li metti in una sottocartella della root chiamata "pippo" (di 5 lettere) devi togliere 6
'al numero che da -14 diventa pertanto -20
'************************************************* ***************
Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Re quest.ServerVariables("PATH_INFO")),pathEnd) & c &"/"& filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
%>
<center>
<table>
<tr>
<td><font face = Verdana size = 2>Il file <%=filename%> è stato copiato con successo nella cartella tuosito.it<%= c%>.</font></td>
</tr>
</table>
<CENTER><FORM>
<INPUT TYPE="button" VALUE="indietro" onClick="history.back()">
</FORM></CENTER>
</center>
</body>
</html>
e questo il file upolad.asp
<%
Server.ScriptTimeout = 3600
Response.Buffer = TRUE
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("Conte nt-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("filen ame="))
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),Requ estBin,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%>
Il limite e' impostato a 1,5 mb e lo rispetta, ma vorrei che quando il file supera la dimensione invece che questo errore
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'MidB'
/data/uploaddiss/upload.asp, line 36
mi scrivesse un messaggio di errore impostato da me.... come posso fare. Grazie a tutti

Rispondi quotando