[PHP] Re: file creation question

2002-08-29 Thread MikeTsapenko

Hello, John.

Just use such code:

  header("Content-type: application/octet-stream");
  header("Content-Disposition: attachment; filename=\"$item[file_name]\"");
  header("Content-length: ".strlen($item[file_content]));
  echo $item[file_content]

This should work...

--

Mike Tsapenko
Chief of Web-development Dept.
AlarIT
http://www.AlarIT.com


"John Hegele" <[EMAIL PROTECTED]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm currently building a site for a band and one of the features I'd like
to
> offer is vCalendar files that the user can download.  I'd like to be able
to
> pull values from a database to use in the file, but, rather than having
the
> actual file on the server, I was hoping that I could create the file
> dynamically when the user clicks on a link.  I think this is possible from
> some information I've come across.
>
> My question here is not regarding anything having to do with the database,
> I'm very familiar with how to pull data from a database with PHP.  I just
> can't figure out how I can generate a file, fill it with values from the
> database and allow the user to download it without the file ever really
> existing on the server.
>
> Thanks in advance for any help you can give.
>
> John
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Attachements

2002-08-26 Thread MikeTsapenko


"Oliver Witt" <[EMAIL PROTECTED]> ???/ ? 
?: news:[EMAIL PROTECTED]...
> Hi,
> Can you attach files to emails and send them through a php script? If
> so, how?
> Kind regards,
> Oliver
>

You can use this function. It can attach just one file.
$mode = message type: plain (default) or HTML otherwise

function
SendMail($email,$subject,$body,$from="",$mode="plain",$file_name="",$file_ty
pe="",$no_template=0)
{
 $body_prefix="";
 $body_suffix="";
 $from_suffix="";

 if(!empty($file_name))
 {
  $file=fopen($file_name,"r");
  if($file)
  {
   $file_content="";
   while(!feof($file))
$file_content.=fread($file,4096);
   fclose($file);

   $file_name=basename($file_name);

   $body_prefix="This is a multi-part message in MIME format.

--Part012345678
Content-Type: text/$mode; charset=\"ISO-8859-1\"

";
   $body_suffix="

--Part012345678
Content-Type: ".( empty($file_type) ? "application/octet-stream" :
$file_type )."; name=\"$file_name\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$file_name\"

".chunk_split(base64_encode($file_content))."
--Part012345678--
";
   $from_suffix="
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"Part012345678\"";
  }
 }
 else
 {
   $from_suffix="
MIME-Version: 1.0
Content-Type: text/$mode; charset=\"ISO-8859-1\"";
 }


$result=@mail(trim($email),trim($subject),$body_prefix.$body.$body_suffix,"F
rom: ".$from.$from_suffix);
 return $result;
}

WBR,
Mike Tsapenko
Chief of Web-development Dept.
AlarIT
http://www.AlarIT.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php