Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Newbie Questions (http://www.greenguysboard.com/board/forumdisplay.php?f=5)
-   -   How to add image attachment within a form (http://www.greenguysboard.com/board/showthread.php?t=37834)

BigVikingAl 2007-01-28 09:55 AM

How to add image attachment within a form
 
I have created a form with my hosts form mail utility but want to include fields that allow image attachments. How can I do this?

HowlingWulf 2007-01-28 03:09 PM

Code:



cd34 2007-01-28 03:21 PM

HTML:
Code:





Some php code to deal with the input:
Code:

    if (!(file_exists($_FILES['uploadedfile']['tmp_name']))) {
      $error .= "Please try again, I didn't get a file. ";
    } else {
      // do something with the file
    }


BigVikingAl 2007-01-28 04:04 PM

Howling Wulf,

I have tried your input field and submitted a form but the resulting output gives me a local file that I can't open.

ie: E:\\My Pictures\\2006-03-23, Rumbelinas II\\Rumbelinas II 001.jpg

since this file is on my computer only how could I open an image if somebody submitted one to me and it was located on their local harddrive, not a server?

cd34,

I do not understeand where I would put your code(s) in my form

HowlingWulf 2007-01-28 04:28 PM

The input field is put between the
tags, and you'll need code to handle the uploaded file. cd34's post has full details you need.

BigVikingAl 2007-01-28 04:42 PM

But where do I put cd34's code?

cd34 2007-01-28 05:19 PM

Generally, I would do something like

Code:

    if (!(file_exists($_FILES['uploadedfile']['tmp_name']))) {
      $error .= "Please try again, I didn't get a file. ";
    } else {
      // do something with the file
      header("Location: /thanks_for_your_upload.html");
      exit;
    }
?>
Upload your file:




Of course, you might want other input fields, insert records into a database, etc, but, the very basic framework you need to upload an image and process it is right there.

BigVikingAl 2007-01-29 02:49 PM

So do I place the php code in a seperate file? Do I point my form action to this php file? Right now here is my form:


















Attach Photo 1:


Attach Photo 2:



    









and here is my output:


Below is the result of your feedback form. It was submitted by
Unknown Stranger (nobody@servage.net) on January 29th, 2007

submit: Submit
email: nobody@servage.net
realname: Unknown Stranger





if I remove the enctype="multipart/form-data"

I at least get a return of an image pointing to a local file:


Below is the result of your feedback form. It was submitted by
Unknown Stranger (nobody@servage.net) on January 29th, 2007

picture1: C:\\Documents and Settings\\Al\\My Documents\\Invoices\\inv22.jpg
picture2: C:\\Documents and Settings\\Al\\My Documents\\Invoices\\inv23.jpg
submit: Submit
email: nobody@servage.net
realname: Unknown Stranger


I want people to upload files with their forms. Is this a server issue as the form is being pointed to a page controlled by them through the form action attribute?

BigVikingAl 2007-02-09 10:00 AM

Finally got one at:

http://www.hiqformmail.com/starting.html

Thanks guys


All times are GMT -4. The time now is 06:46 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc