codice:
Private Function pUpLoad()
Dim index,elm,i,EndOfFile,arPosBeg(),arPosEnd(),arPosName(),SizeStream,nE,BytesToRead,Header ,arContent,ar,tmp
Dim PosBeg,PosEnd,Name,FileName,ContentType,StreamType,Boundary,Content,boundaryLen,boundaryPos,Pos,arV,fieldValue
If EnabledLog then CreateFolder iLogFolder
If iTotalBytes>0 then
If Request.ServerVariables("HTTP_CONTENT_TYPE")="application/x-www-form-urlencoded" then
Content = BinaryStringRead()
ar = split(Content,"&")
for each elm in ar
arV = split(elm,"=")
Index = URLDecode(arV(0))
on error resume next
FieldValue = URLDecode(arV(1))
on error goto 0
AddToForm Index,FieldValue
next
else
IsMultipart = True
InitUploadFiles()
BinaryRead()
'**** Deteterminazione Boundary ****
SizeStream = Stream.Size
RequestBin = Stream.Read(60)
PosBeg = 1:PosEnd = InstrB(PosBeg,RequestBin,c13b)
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryLen = LenB(boundary):boundaryPos = 1
'**** End OF File Position ****
EndOfFile = SizeStream - boundaryLen - 3
'**** Salvataggio Posizione di Boundary *****
Stream.Position = 0
RequestBin = Stream.Read()
nE = -1:Pos = 1
do
PosBeg = InStrB(Pos,RequestBin,boundary)
if PosBeg>0 then
PosBeg = InStrB(PosBeg + boundaryLen,RequestBin,cName)
PosEnd = InstrB(PosBeg+1,RequestBin,boundary)
If PosEnd >0 then
nE = nE + 1
redim preserve arPosBeg(nE)
redim preserve arPosEnd(nE)
redim preserve arPosName(nE)
arPosBeg(nE) = PosBeg
arPosEnd(nE) = PosEnd
tmp = InStrB(PosBeg + 1,RequestBin,cContentType)
arPosName(Ne) = 0
If tmp<PosEnd then
arPosName(Ne) = tmp
end if
if arPosName(Ne) = 0 then
arPosName(Ne) = InStrB(PosBeg + 1,RequestBin,c13b) + 3
end if
end if
Pos = PosEnd
end if
loop until Pos=EndOfFile
for i=0 to nE
FileName=""
Stream.Position = arPosBeg(i)-1
Header = Split(BinaryToString(Stream.Read(arPosName(i)-arPosBeg(i))),"; ")
if uBound(Header)>0 then
on error resume next
execute Header(0) & ":" & Header(1)
if err.number<>0 then
response.write err.description &"
"
response.write Header(0) & ":" & Header(1)
response.end
end if
on error goto 0
If FileName<>"" then
Stream.Position = arPosName(i)-1
RequestBin = Stream.Read (60)
Pos = InStrB(1,RequestBin,c13b)
ContentType = BinaryToString(MidB(RequestBin,1,Pos-1))
arContent = Split(ContentType,": ")
ContentType = arContent (1)
StreamType=1 : If InStr(ContentType,"text/")>0 then StreamType=2
PosBeg = arPosName(i) + Pos + 2
Stream.Position = PosBeg
RequestBin = Stream.Read (arPosEnd(i)-PosBeg-3)
AddNewRs Name,FileName,ContentType,StreamType,RequestBin
if LoadFilesInForm then AddToForm Name,FileName
else
Form(Name) = ""
end if
else
Execute Header(0)
Stream.Position = arPosName(i)
RequestBin = Stream.Read(arPosEnd(i)-arPosName(i)-3)
AddToForm Name,BinaryToString(RequestBin)
end if
next
IsDataLoad = True
Stream.Close
MoveFirst
end if
End if
End function
il file che provo ad uploadare non contiene caratteri speciali o altro....