Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13
  1. #1

    Problema con form upload

    Salve. Ho scaricato il seguente script per l'upload di file dal vostro sito ASP:
    codice:
    <%
    'Stores only files with size less than MaxFileSize
    
    'notification address 
    Const NotifyAddress = "info@lasfidacontinua.it"
    
    
    Dim DestinationPath, rHTML
    DestinationPath = Server.mapPath("UploadFolder")
    
    'Create upload form
    'Using Huge-ASP file upload
    'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
    'Using Pure-ASP file upload
    Dim Form: Set Form = New ASPForm %><% 
    
    Server.ScriptTimeout = 2000
    Form.SizeLimit = &HA00000
    
    '********************** Form processing
    
    '{b}Set the upload ID for this form.
    'Progress bar window will receive the same ID.
    if len(Request.QueryString("UploadID"))>0 then
    	Form.UploadID = Request.QueryString("UploadID")'{/b}
    end if
    
    
    'was the Form successfully received?
    Const fsCompletted  = 0
    If Form.State = fsCompletted Then 'Completted
      'was the Form successfully received?
      if Form.State = 0 then
        'Do something with upload - save, enumerate, ...
        rHTML = rHTML &  "
    Upload result: Form was accepted." 
        rHTML = rHTML &  "
    Number of file fields:" & Form.Files.Count
        rHTML = rHTML &  "
    Request total bytes:" & Request.TotalBytes
    		Form.Files.Save DestinationPath 
    		rHTML = rHTML &  "
    Files was saved to " & DestinationPath & " folder."
      End If
    ElseIf Form.State > 10 then
      Const fsSizeLimit = &HD
      Select case Form.State
    		case fsSizeLimit: rHTML = rHTML &   "
    <Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font>
    "
    		case else rHTML = rHTML &  "
    <Font Color=red>Some form error.</Font>
    "
      end Select
    End If'Form.State = 0 then
    
    response.write rHTML
    
    '********************** Notification
    
    if Request.ServerVariables("REQUEST_METHOD") = "POST" then
    	'Create a report email
    
      Set objNewMail = CreateObject("CDONTS.NewMail")
      Const CdoMailFormatMime = 0
      objNewMail.MailFormat = CdoMailFormatMime
    	objNewMail.BodyFormat = 0 ' HTML
    	Subject = "Upload of files - user '" & request.servervariables("REMOTE_USER") & "'"
    	Message = rHTML
    	Message = Message & "
    
    Time: " & Now
    	Message = Message & "
    Total size:" & Form.TotalBytes & "B (" & Form.TotalBytes \1024 + 1 &  "kB)"
    	Message = Message & "
    Fields:" 
    
    	Dim Field
    	For each Field In Form.Items.Items
    		Message = Message  & "
    " & Field.Name & ":" 
    		if Field.isFile then
    			if len(Field.FileName)>0 then
    				Message = Message  & " file " & Field.FileName & "," & Field.Length \1024 + 1 & "kB"
    			else'if len(Field.FileName)>0 then
    				Message = Message  & " empty file field."
    			end if'if len(Field.FileName)>0 then
    		else'if Field.isFile then
    			Message = Message  & " text '" & Field.String & "'"
    		end if 'if Field.isFile then
    	Next
      
      'Send the new email
      objNewMail.Send "Huge-ASP upload", NotifyAddress, Subject, Message
    End If
    
    
    
    '********************** HTML Form prepare
    '{b}get an unique upload ID for this upload script and progress bar.
    Dim UploadID, PostURL
    UploadID = Form.NewUploadID
    
    'Send this ID as a UploadID QueryString parameter to this script.
    PostURL = Request.ServerVariables("SCRIPT_NAME") & "?UploadID=" & UploadID'{/b}
    
    %>  
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
     <TITLE>ASP huge file upload - upload with administrator email notification.</TITLE>
     <STYLE TYPE="text/css"></STYLE>
     <meta name="robots" content="noindex,nofollow">
    </HEAD>
    <BODY BGColor=white>
    
    
    <Div style=width:600>
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      
      <TR>
        <TH noWrap align=left width="20%" bgColor=khaki><A 
          href="http://asp-upload.borec.net">Power ASP 
          file upload</A> - upload with administrator email notification.</TH>
        <TD></TD></TR></TABLE>
    <TABLE cellSpacing=2 cellPadding=1 width="100%" bgColor=white border=0>
      
      <TR>
        <TD colSpan=2>
          
    
    
    
            Form size limit is <%=Form.SizeLimit \ 2048 %>kB
    
    Destination folder is <%=DestinationPath%>
    
    Administrator email address <%=NotifyAddress%>
    
    
    			</P>
      </TD></TR></TABLE>
    
    <form name="file_upload" method="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">
    <Div ID=files>
       File 1 : <input type="file" name="File1">
    
       File 2 : <input type="file" name="File2">
    
       File 3 : <input type="file" name="File3">
    </Div>
    
    <Input Type=Button Value="Aggiungi un file" OnClick=return(Expand()) 
     Style="border=0;background=yellow;cursor:hand">
    
    
    
    Descrizione: 
    <input Name=Description1 Size=60>
    
    <input Name=SubmitButton Value="Invia &raquo;" Type=Submit>
    
    
    </Form>
    
    <SCRIPT>
    //Open window with progress bar.
    function ProgressBar(){
      var ProgressURL
      ProgressURL = 'progress.asp?UploadID=<%=UploadID%>'
    
      var v = window.open(ProgressURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=200')
      
      return true;
    }
    </SCRIPT> 
    
    <Script>
    //Expand form with a new File fields if needed.
    var nfiles = 3;
    function Expand(){
      nfiles++
      var adh = '
     File '+nfiles+' : <input type="file" name="File'+nfiles+'">';
      files.insertAdjacentHTML('BeforeEnd',adh);
      return false;
    }
    </Script>
    
    
    
    
    
    <HR COLOR=silver Size=1>
    <CENTER>
    <FONT SIZE=1>© 1996 – <%=year(date)%> Antonin Foller, Motobit Software, e-mail help@pstruh.cz
    
    To monitor current running uploads/downloads, see IISTracer - IIS real-time monitor.
    </FONT>
    
    </CENTER>
    </Div>
    </BODY></HTML>
    Ho riscontrato però due errori:
    1) La mail di conferma di upload non viene inviata (dovrebbe farlo );
    2) L'upload viene eseguito correttamente, solo che successivamente viene aperta la pagina "Impossibile visualizare la pagina".

    Potete gentilmente aiutarmi a risolvere questi due problemi?
    Grazie mille
    Roberto
    OnLine il nuovo sito: www.lasfidacontinua.it

  2. #2
    1)Lo script usa CDONTS. Soluzione : per l'invio delle email usa CDOSYS (evidentemente sei su Windows 2003 server)
    2)Evidentemente non trova il file "progress.asp" che è il file che mostra la barra di avanzamento dell'upload. Soluzione: elimina la parte dello script
    codice:
    <SCRIPT>
    //Open window with progress bar.
    function ProgressBar(){
      var ProgressURL
      ProgressURL = 'progress.asp?UploadID=<%=UploadID%>'
    
      var v = window.open(ProgressURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=200')
      
      return true;
    }
    </SCRIPT>
    se non vuoi la barra di avanzamento e se non vuoi far comparire l'errore di pagina non trovata.

  3. #3
    Ciao, grazie per la risposta.
    1) come faccio a sostituirlo? Puoi suggerismelo tu oppure consigliarmi un tutorial?
    2) L'errore avviene dopo che viene aperta la finestra "progress.asp". Quando chiama questa pagina, dopo il popup, "Upload-Notification.ASP?UploadID=760340864", mi dice "Errore 500: Impossibile visualizzare la pagina".

    Grazie
    OnLine il nuovo sito: www.lasfidacontinua.it

  4. #4
    Originariamente inviato da rob_santini
    Ciao, grazie per la risposta.
    1) come faccio a sostituirlo? Puoi suggerismelo tu oppure consigliarmi un tutorial?
    2) L'errore avviene dopo che viene aperta la finestra "progress.asp". Quando chiama questa pagina, dopo il popup, "Upload-Notification.ASP?UploadID=760340864", mi dice "Errore 500: Impossibile visualizzare la pagina".

    Grazie
    Quasi sicuramente l'errore è dovuto al mancato invio dell'email di notifica.
    Se fai una ricerca per "CDOSYS" sul forum troverai senz'altro la soluzione, è stato discusso ampiamente, oppure puoi cercare con il famigerato google "da cdonts a cdosys"

    Resta il fatto che se non ti serve la notifica dell'upload puoi sempre commentare o eliminare le righe interessate e cioè:
    codice:
    '********************** Notification
    
    if Request.ServerVariables("REQUEST_METHOD") = "POST" then
    	'Create a report email
    
      Set objNewMail = CreateObject("CDONTS.NewMail")
      Const CdoMailFormatMime = 0
      objNewMail.MailFormat = CdoMailFormatMime
    	objNewMail.BodyFormat = 0 ' HTML
    	Subject = "Upload of files - user '" & request.servervariables("REMOTE_USER") & "'"
    	Message = rHTML
    	Message = Message & "
    
    Time: " & Now
    	Message = Message & "
    Total size:" & Form.TotalBytes & "B (" & Form.TotalBytes \1024 + 1 &  "kB)"
    	Message = Message & "
    Fields:" 
    
    	Dim Field
    	For each Field In Form.Items.Items
    		Message = Message  & "
    " & Field.Name & ":" 
    		if Field.isFile then
    			if len(Field.FileName)>0 then
    				Message = Message  & " file " & Field.FileName & "," & Field.Length \1024 + 1 & "kB"
    			else'if len(Field.FileName)>0 then
    				Message = Message  & " empty file field."
    			end if'if len(Field.FileName)>0 then
    		else'if Field.isFile then
    			Message = Message  & " text '" & Field.String & "'"
    		end if 'if Field.isFile then
    	Next
      
      'Send the new email
      objNewMail.Send "Huge-ASP upload", NotifyAddress, Subject, Message
    End If

  5. #5
    Ciao.
    Ho trovato come sostituire, ma quando provo la pagina, mi da errore a questa riga:
    codice:
    To = "info@lasfidacontinua.it"
    Il codice che ho inserito al posto di quello vecchio è questo:
    codice:
    '*****************Nuova mail
    
        Dim MyMail
        Set MyMail = Server.CreateObject("COD.Message")
        With MyMail
            To = "info@lasfidacontinua.it"
            From = "IlMioSitoWeb@2fCMS.it"
            Subject = "Nuovo Download inserito"
            TextBody = "Ciao WebMaster, è eppena stato inserito un nuovo download nel tuo sito:" & "
    
    Ora: " & Now& "
    Dimensione totale:" & Form.TotalBytes & "B (" & Form.TotalBytes \1024 + 1 &  "kB)"& "
    Fields:" 
    
    	Dim Field
    	For each Field In Form.Items.Items
    		Message = Message  & "
    " & Field.Name & ":" 
    		if Field.isFile then
    			if len(Field.FileName)>0 then
    				Message = Message  & " file " & Field.FileName & "," & Field.Length \1024 + 1 & "kB"
    			else'if len(Field.FileName)>0 then
    				Message = Message  & " empty file field."
    			end if'if len(Field.FileName)>0 then
    		else'if Field.isFile then
    			Message = Message  & " text '" & Field.String & "'"
    		end if 'if Field.isFile then
    	Next
            Send
        End With
        Set MyMail = Nothing
    OnLine il nuovo sito: www.lasfidacontinua.it

  6. #6
    Utente di HTML.it L'avatar di viki1967
    Registrato dal
    Feb 2003
    Messaggi
    1,757
    codice:
    .To = "info@lasfidacontinua.it"
    A S P : tutto il resto è noia...
    L I N U X : forse mi "converto"...

  7. #7
    Che velocità!
    Cmq, ora l'errore è un altro:

    Set MyMail = Server.CreateObject("COD.Message")

    OnLine il nuovo sito: www.lasfidacontinua.it

  8. #8

  9. #9
    Ok. Ora funziona tutto.
    Grazie mille
    OnLine il nuovo sito: www.lasfidacontinua.it

  10. #10

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.