Web Analytics Made Easy -
StatCounter Need to Include Attachment Option to Form - CodingForum

Announcement

Collapse
No announcement yet.

Need to Include Attachment Option to Form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to Include Attachment Option to Form

    Hello,

    I'm not sure I'm posting this in the right area.

    I have a form that I need to include an option to attach documents if needed.
    I have two files: an html file and an asp file

    Code:
     (html file)
    <div id="webposting">
            <div class="webform5">		
            <form method="post" action="/forms/web_postinghandler.asp" name="webposting" id="webposting">   
                          
                    
    <label>Contact Name:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Name" maxlength="100" size="50" />
    <br /><span class="red">* (Required)</span></div>			
    <p style="clear:both"></p>
    
    <label>E-Mail Address:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Email" maxlength="100" size="50" />
    <br /><span class="red">* (Required)</span><br /></div>		
    <p style="clear:both"></p>
                        
     <label>Location/Department:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Location" maxlength="100" size="50" />
    <br /><span class="red">* (Required)</span><br /></div>		
    <p style="clear:both"></p>
                        
    <label>Phone:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Phone" maxlength="100" size="50" />
    <br><span class="red">* (Required)</span></div>
    <p style="clear:both"></p>	
                        
    <label>Title of Program:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Title" maxlength="100" size="50" />
    <br /><span class="red">* (Required)</span><br /></div>		
    <p style="clear:both"></p>	
                        
    <label>Date of Program:</label>
    <div class="left"><input type="text" class="blue_form_box" name="Date" maxlength="100" size="50" />
    <br /><span class="red">* (Required)</span><br /></div>	
    <p style="clear:both"></p>
                        
    <label>Other Requests:<br> (change or addition to policies, procedures, etc.)</label>
    <div class="left"><textarea class="blue_form_box" name="Changes" rows="5" cols="50"></textarea></div>					
    <p style="clear:both"></p>					
    						
    <div align="center">						<input type="submit" value="Submit" />                
    	<input type="reset" value="Erase Typing" /></div>
    				
    </form>			
    </div></div>
    _____________________________________________________________
    Code:
     (asp file)
    
    <div class="webform5">		
    			
    <%
    Dim MsgBody, TargetDept, TargetSubject    
     TargetDept = "Technical Support"
     TargetEmail = "[email protected]"
     TargetSubject = "Website Posting Form for Program Information"
     MsgBody = "The following information was submitted by " & Request.Form("Name")
    MsgBody = MsgBody & vbCRLF & vbCRLF
    MsgBody = MsgBody & "Attached File: " & Request.Form("filefield") & vbCRLF & vbCRLF
    MsgBody = MsgBody & "Title of Program: " & Request.Form("Title") & vbCRLF & vbCRLF
    MsgBody = MsgBody & "Date of Program: " & Request.Form("Date") & vbCRLF
    MsgBody = MsgBody & "Contact Name: " & Request.Form("Name") & " " & Request.Form("Name") & vbCRLF & vbCRLF
    MsgBody = MsgBody & "Location/Department: " & Request.Form("Location") & vbCRLF & vbCRLF
    MsgBody = MsgBody & "Telephone: " & Request.Form("Phone") & vbCRLF & vbCRLF  
    MsgBody = MsgBody & "Email Address: " & Request.Form("Email") & vbCRLF & vbCRLF	
    	
    %>
    
    <p><strong>Recap of submission:</strong></p>
    <p><strong>Subject:</strong></p> <% Response.Write(TargetSubject) %> 
    <p><strong>Department:</strong></p> <% Response.Write(TargetDept) %> 
    <p><strong>Your Information:</strong></p> <% Response.Write(MsgBody) %>
    
    <%
    Set objEmail = CreateObject("CDO.Message")
    	objEmail.From = "[email protected]"
    	objEmail.To = TargetEmail
    	objEmail.Subject = TargetSubject
    	objEmail.Textbody = MsgBody
    	objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    	objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
            "smtp.coj.net" 
    	objEmail.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    	objEmail.Configuration.Fields.Update
    	objEmail.Send	
    %>
    Now the big question is, how do I make this so that the person can attach a document?

    Thanks for your help, Elbee
    Last edited by oracleguy; Aug 31, 2011, 06:12 PM. Reason: fixed code tags

  • #2
    The input element has a type attribute of "file" that allows users to browse their local files and upload a file or image.
    Teed

    Comment


    • #3
      And then you have to also have a file uploader component on your web server. You *can* use a "pure VBScript" uploader (and there are tons of them out there...also called "pure ASP uploaders"), but better is an uploader ActiveX control if your web host supports one.

      This is dated, but still *most* of the links work:


      Don't forget to change the form's encoding type:
      Code:
      <form action="yourpage.asp" enctype="multipart/form-data" method="post">
      Be yourself. No one else is as qualified.

      Comment


      • #4
        Thanks as always "Oh Great One!!!!"

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎