Results 1 to 3 of 3

Thread: image to form

  1. #1
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default image to form

    i am having an issue. i am sure this has been done a million and one times. i am not too good at website design and scripts. so i understand some basic stuff. was wondering if someone can help me with a form.
    what i am looking to do is have a user fill out a form and click submit and it sends it to my email. easy! that i can do.
    now the problem is-- i was wanting the same user to be able to choose a file (upload) and it is submitted with their info on the form. so when i open my email i see the image as an attachment. is this even possible?
    can anyone help?
    i know my server supports php. i don't understand cgi, cgi-bin either.

    as i said-- i am pretty basic-- so step by step would be very helpful when routing and uploading the files/scripts i need



    Code:
    <FORM ACTION="/cgi-sys/formmail.cgi" METHOD="POST"> 
    <input type=hidden name="recipient" value="yourmail@yourdomain.com"> 
    <input type=hidden name="subject" value="Siteground Test"> 
    <BR> 
    <BR> 
    <TABLE> 
     <TR> 
      <TD>Name:</TD> 
      <TD> 
       <input type=text name="name"> 
      </TD> 
     </TR> 
      <TR> 
      <TD>Feedback:</TD> 
      <TD> 
       <input type=text name="feedback"> 
      </TD> 
     </TR> 
     <TR> 
      <TD> 
       <input type="reset" value="Reset" name="Reset"> 
      </TD> 
      <TD> 
       <input type="submit" value="Submit" name="Submit"> 
      </TD> 
     </TR> 
    </TABLE> 
    </FORM>

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This is possible, but complex. In short, file attachments to emails are difficult to get working in PHP because it must be done through a few steps.

    First, look up a form mailer in PHP and get that working. (On YOUR server, NOT hosted somewhere else, or the attachment probably won't be allowed.)

    Second, loop up information on how to upload files in PHP.

    Third, and here is the hardest part, loop up information on attachments in php-generated email.

    Information on all of this is available on php.net (a great reference for do-it-yourself work), and there are also tutorials available (use google, there are lots) for each of these, but you may not get one that explains ALL of it, so go step by step.

    It's very possible, just might take a little while to get setup.

    Once you have a little clearer idea how to approach the problem, feel free to ask for more help with the specifics.

    Also, the html is almost entirely unrelated to this, just how you submit your data. Any html form will work as long as you have the required parts. A <input type="file"> tag will give you the way to upload an image. Look at the tutorials for more information.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2008
    Posts
    58
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default

    There are a few extra steps for handling file upload and then attaching a file to the email.

    There is a library 'Pear' for PHP. Using this library, it is easier.

    The page below has some sample code:
    How to create PHP email form with file attachment

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •