Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2003
    Messaggi
    109

    upload di più file in asp

    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

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    questo
    codice:
    Const nForReading = 1
    Const nForWriting = 2
    Const nForAppending = 8
    mettilo prima del do while

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.