Salve a tutti, ho esigenza di effettuare un upload di due file in simultanea.
Parto da un form molto semplice con due file:
<FORM method="post" encType="multipart/form-data" action="link">
<INPUT name="File1" type="file"><br><br>
<INPUT name="File2" type="file"><br><br>
<INPUT type="Submit" value="Upload">
</FORM>
il file .asp al quale rimanda il form è il seguente
!--#INCLUDE FILE="APP_clsUpload.asp"-->
<%
i=1
Do While (i <= 2)
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("File"&i)
' 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("..\PUBLIC\banner\home\"&request.qu erystring("cod")&"\")
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
oFSO.OpenTextFile(sPath &"\"& sFileName, nForWriting, True).Write sNewData
Set oFSO = Nothing
Set oFile = Nothing
Set oUpload = Nothing
'RINOMINO IL FILE
Dim fs
Set fs = Server.CreateObject("Scripting.FileSystemObject")
if i=1 then nome="thumb" end if
if i=2 then nome="img" end if
fs.MoveFile sPath&"\"&sFileName, sPath&"\"&nome&".jpg"
Set fs = nothing
i=i+1
Loop
%>
Purtroppo l'upload del primo file funziona ma quando ripete il ciclo la seconda volta mi ritorna l'errore
Errore di run-time di Microsoft VBScript error '800a0411'
Nome ridefinito: 'nForReading'
/SICOI/SITO/2.0/BEforMANAGE/APP_uploadfile1.asp, riga 17
Sapete aiutarmi?
Grazie

Rispondi quotando