I m using the following attachment handling code in my web client
?
// supposing that:
// $encoding = 'BASE64';
// $pid = attachment's pid;
// $file = attachment's file name;
// $size = $object-bytes;
// $type = $object-type;
// $subtype = $object-subtype;
//...
$attch = imap_base64(imap_fetchbody($mbox, $id, $pid));
//...
$types = array(text, multipart, message, application, audio,
image, video, other);
$cont_type = $types[$type]./.$subtype;
header(Content-transfer-encoding: binary\n);
header(Content-type: $cont_type\n);
if (strstr($_SERVER[HTTP_USER_AGENT], MSIE))
header(Content-Disposition: filename=$file\n); // For IE
else
header(Content-Disposition: attachment; filename=$file\n); // For non-IE
browsers
header(Content-length: $size\n );
print $attch;
?
Regardless the nature of the attachment, things are happening expectedly (as
far as I tested) as long as the SAVE button of the browser's save-file
dialog is clicked.
The OPEN button works fine as well, for browser compatible files such as
.jpeg, .gif, .txt, etc...
But when it's matter of opening per ex. a MSPoverPoint *.pps slide-show file
as attachment through the browser's save-file dialog (well, the button is
there and any user may click it) the smooth running web client turns into a
PoverPoint application opened through the browser's window with an empty
project in design view.
Wrapping above code with
?
$tmpfname = tempnam (0, 0);
$fp = fopen($tmpfname, w);
fwrite($fp, $attch);
fclose($fp);
...
unlink($tmpfname);
?
didn't help too much.
Would there be a way to force the browser to download the attachment in a
temporary location and launch the application (MSPowerPoint in this case) by
its own?
Okar
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php