Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    684

    upload dei file + invio dati utente tramite email

    Premetto che sono un novizio e mi sono affacciato da poco al mondo della programmazione ASP.

    Questo script per l'invio dei file e' ottimamente realizzato, grazie anche al fatto che non ha limiti di capacità per quanto riguarda i file da mandare.

    Ho un problema, insormontabile per me, vorrei inserire al form dei campi di inserimento testo (<INPUT type="text" name="nome"> e (<textarea name="messaggio" ecc.>) ed inviarli ad un'mail prestabilita. Al codice pre-esistente potete dirmi il codice da aggiungere ed in quale inserirlo se nell'upload.asp o save.asp (prendo in esame gli script di Baol74).

    Qui di seguito vi inserisco lo script asp che uso come form email:

    kontact.htm (il form)
    email.asp
    upload.asp
    save.asp

    Come potete vedere per ovviare al problema ho risolto così ma non mi soddisfa.

    Vi chiedo se si puo' modificare questo oppure ricreare ex novo.

    FILE "KONTACT.htm" modulo compilazione:

    <form method="post" enctype="multipart/form-data" action="inviofile.asp" >


    <font face="Arial, Helvetica, sans-serif" size="1">NOME:
    <input type="text" name="nome" >
    COGNOME:
    <input type="text" name="cognome">


    email:
    <input type="text" name="email">
    telefono:
    <input type="text" name="telefono">
    </font></p>


    <font face="Arial, Helvetica, sans-serif" size="1">messaggio:</font>

    <textarea name="messaggio" maxlenght="500" cols="54" rows="5"></textarea>
    </p>


    <font face="Arial, Helvetica, sans-serif" size="1">File :</font>
    <input type="file" name="blob">
    <font face="Arial, Helvetica, sans-serif" size="2">tipo di file: </font>
    <select name="select" size="1">
    <option>IMMAGINE</option>
    <option>AUDIO</option>
    <option>TESTO</option>
    <option>VIDEO</option>
    </select>


    <font face="Arial, Helvetica, sans-serif" size="1">[clicca su sfoglia per
    allegare un file]</font>

    </p>



    <input type="submit" name="invia" value="Invia">
    <input type="reset" name="reset" value="Reimposta">
    </p>
    </form>

    FILE "inviofile.asp":


    <%
    Dim oUpload
    Set oUpload = new cUpload
    oUpload.AutoRename = False
    oUpload.OverWrite = True
    oUpload.Load()
    oUpload.SetPath oUpload.Form("Select")
    While Not oUpload.EOF
    oUpload.Save()
    Response.Write "Salvo il file : " & oUpload.GetFileName() & "
    "
    oUpload.MoveNext
    Wend
    Set oUpload=Nothing
    %>

    ed il file del form email da inglobare, se possibile:

    <%

    'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
    Response.Buffer = TRUE

    'Dimension variables
    Dim strBody 'Holds the body of the e-mail
    Dim objCDOMail 'Holds the mail server object
    Dim strMyEmailAddress 'Holds your e-mail address
    Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
    Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
    Dim strReturnEmailAddress 'Holds the return e-mail address of the user


    '----------------- Place your e-mail address in the following sting ----------------------------------

    strMyEmailAddress = "frantome5@tin.it"

    '----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------

    strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail

    '----------- Place Blind Copy e-mail address's in the following sting, separated by ; --------------

    strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail

    '-----------------------------------------------------------------------------------------------------


    'Read in the users e-mail address
    strReturnEmailAddress = Request.Form("email")


    'Initialse strBody string with the body of the e-mail
    strBody = "<h2>Mi hanno contattato!</h2>"
    strBody = strBody & "
    Nome: " & Request.Form("nome") & " " & Request.Form("cognome")
    strBody = strBody & "
    telefono: " & " " & Request.form("telefono")
    strBody = strBody & "
    E-mail: " & " " & strReturnEmailAddress
    strBody = strBody & "

    Messaggio:
    " & " " & Request.Form("messaggio")

    'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
    If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then

    'Set the return e-mail address to your own
    strReturnEmailAddress = strMyEmailAddress
    End If


    'Send the e-mail

    'Create the e-mail server object
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

    'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
    objCDOMail.From = Request.Form("nome") & " " & Request.Form("cognome") & " <" & strReturnEmailAddress & ">"

    'Who the e-mail is sent to
    objCDOMail.To = strMyEmailAddress

    'Who the carbon copies are sent to
    objCDOMail.Cc = strCCEmailAddress

    'Who the blind copies are sent to
    objCDOMail.Bcc = strBCCEmailAddress

    'Set the subject of the e-mail
    objCDOMail.Subject = "Contatto dal sito www.marcogreco.com"

    'Set the e-mail body format (0=HTML 1=Text)
    objCDOMail.BodyFormat = 0

    'Set the mail format (0=MIME 1=Text)
    objCDOMail.MailFormat = 0

    'Set the main body of the e-mail
    objCDOMail.Body = strBody

    'Importance of the e-mail (0=Low, 1=Normal, 2=High)
    objCDOMail.Importance = 1

    'Send the e-mail
    objCDOMail.Send

    'Close the server object
    Set objCDOMail = Nothing

    %>


    Vi sarei grato se poteste risolvere questo prob.
    Grazie anticipatamente.

    Ricapitolando mi servirebbe un form che mi permetta di inviare dati NOME, COGNOME, email, ecc e UPLOADARE file.

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    L'upload di baol consente tutto questo.
    Scaricati lo zip e dentro trovi gli esempi se non sbaglio.

    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    684
    si ho scaricato lo zip. Ma i vari esempi permettono la gestione diversa degli upload... il file .htm del form contiene solo input type="file" e non quello per i dati... quindi anche gli script...

    se sbaglio correggimi.

    grazie

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    I campi di testo si recuperano semplicemente così:

    Set oUpload = new cUpload
    'oUpload.AutoRename=False
    'oUpload.OverWrite=True
    oUpload.Upload
    oUpload.SetPath percorso_foto

    'Campi di tipo testo
    concessionario_id = oUpload.Form("concessionario_id")
    marca_id = oUpload.Form("marca_id")
    auto_modello = oUpload.Form("auto_modello")
    auto_descrizione = oUpload.Form("auto_descrizione")
    auto_anno = oUpload.Form("auto_anno")
    auto_prezzo = oUpload.Form("auto_prezzo")
    auto_autore = oUpload.Form("auto_autore")
    auto_autore_email = oUpload.Form("auto_autore_email")
    auto_autore_telefono = oUpload.Form("auto_autore_telefono")


    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    684
    In seguito mi basta inizializzare nella stessa pagina, nel caso del CDONTS l'oggetto CDOMAIL (set objCDOMAIL=Server.CreateObject("CDONTS.NewMail").
    Giusto?... vado bene cosi'... modifico lo script e lo invio... dopo averlo provato, se ci sono prob. vediamo.

    ultima cosa tutto questo va all'interno dello script save.asp, giusto?

    Grazie ROBY

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Si, devi recuperare il file dal server e allegarlo all'email.

    Roby

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.