Re: Attach a file to an email

From: Date: Mon, 19 Jun 2000 14:34:31 +0000
Subject: Re: Attach a file to an email
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2199@lists.php.net to get a copy of this message
In the client side form you have: <FORM ACTION=add_file.php3 ENCTYPE="multipart/form-data" METHOD=POST> <INPUT TYPE=FILE NAME="pic2" SIZE=40> </FORM> And on the server-side php you have: $img = get_image($titlepic, "Title Picture"); Where: function get_image($fsname, $filename) { global $MAX_IMG_SIZE; /* Set by the client, if no file given */ if ($fsname == "none") { return ""; } $stat_array = stat($fsname); if ($stat_array == "") { echo_br("$filename: File does not exist: stat failed"); return ""; } $size = $stat_array[7]; echo_br("$filename: Receive $size bytes"); if ($size > $MAX_IMG_SIZE) { echo_br("$filename: File is too big"); return ""; } echo_br("$filename: Receive $size bytes"); if ($size > $MAX_IMG_SIZE) { echo_br("$filename: File is too big"); return ""; } $fp = fopen($fsname,"r"); if ($fp == "") { echo_br("$filename: Problem openning the file"); return ""; } $fr = fread($fp,$size+1); fclose($fp); unlink($fsname); $img = addslashes($fr); return $img; } Once the file is held in $img you can manipulat it in the same way as you would any other PHP variable. Hope this helps, David. ----- Original Message ----- From: Bård Tommy Nilsen <Bard.Nilsen@chembio.ntnu.no> To: <php-general@lists.php.net> Sent: Monday, June 19, 2000 1:00 PM Subject: [PHP-GENERAL] Attach a file to an email > > HEEELP !! > > Can anyone tell me how to attach a file to an php-script ?? > > I want to make an form that you can browse a file on your computer and > send > it to the webmaster using a form. > The form is sent to an php-script with the mail function > > > Brd Tommy Nilsen

« previous php.general (#2199) next »