Re: Email from HTML form + gifs

From: Date: Sat, 30 Oct 1999 21:38:59 +0000
Subject: Re: Email from HTML form + gifs
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-12030@lists.php.net to get a copy of this message
Hi Gianni : the form may be declared : <form ENCTYPE="multipart/form-data" action="URL" method="post"> and in the form you need put the next line <input type="file" name="image"> this line permit that the user select some file via a select box When the user press the button of submit the file that the ser select will be uploaded to the server and the variable $image ( refer to the manual of php3 for upload here say all about the manipulation of the file ) You must verify if the file have a extension of a image ! Noy you have the image in the server, referred by the variable $image (the path only). Now you need build the message body and the headers of the email NOTE : You need a program called mimencode for encode the file build the header of the email in the next way : $mime_boundary = "-1747901728-1448367683-913849620=:4553"; $headers = ""; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: MULTIPART/MIXED;boundary=\"".$mime_boundary."\"\n"; $headers .= "From : $from\n"; $headers .= "CC : $CC\n"; /* May Be Optional */ $headers .= "Reply-To : $reply\n"; /* May Be Optional */ $body .= " This message is in MIME format. The first part should be readable text,\n"; $body .= " while the remaining parts are likely unreadable without MIME-aware tools.\n"; $body .= " Send mail to mime@docserver.cac.washington.edu for more info.\n"; $body .="\n"; $body .= "--" . "$mime_boundary" . "\n"; $body .= "Content-Type: TEXT/PLAIN; charset=US-ASCII\n"; $body .= "\n"; $body .= PUT THE VARIABLE OF THE BODY OF MESSAGE $body .= "\n\n"; $body .= "--" . $mime_boundary . "\n"; $name = $image_name; $body .= "Content-Type: " . $this->guessMIMEType($nombre) .";name=\"".$name . "\"\n"; $body .= "Content-Transfer-Encoding: BASE64\n"; $body .= "Content-Description: $name\n"; $body .= "Content-Disposition: attachment; filename=\"".$name."\"\n"; $body .= "\n"; $pp = popen("mimencode -b $this->attachment","r"); while(!feof($pp)) { $data = fread($pp,4096); $body .= $data; } pclose($pp); $body .= "--" . $mime_boundary . "--\n"; mail($to,$subject,$body,$headers); NOTE 2 : Be sure that the program mimencode have the rights set to execution to the user that run's apache or the web server Bye LeTe PS : If have any problem drop me a email On Fri, 29 Oct 1999, gianni wrote: > This message was sent from Geocrawler.com by "gianni" <gianni@adept.co.za> > Be sure to reply to that address. > > Greetings > > does someone know how to add pictures to an email sent by an online form ? > > thanks > gianni > > Geocrawler.com - The Knowledge Archive > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#12030) next »