Hi,

When using Internet Exploded to download files from a website which extracts
an file from a mysql db I encounter a weird problem.

How I do this is simple, I use an href link that looks something like this,

downloadcontent.php?PHPSESSID=33f8022176ba48bb8f4421d59d1792a6&attachment_ai
d=3

The following php code should extract a particular attachment from the db,
in this case, attachment_aid 3 and let the user either open or save it.

<?php
// Connect to the MySQL Database
        $mysql_connect  = mysql_pconnect();
        $mysql_dbselect = mysql_select_db("commentum",$mysql_connect);

// Get the current amount of users online on the system
        $mysql_sql              = "select 
attachment_id,attachment_name,attachment_file from
email_attachment where attachment_aid = '$attachment_aid'";
        $mysql_result   = mysql_query($mysql_sql,$mysql_connect) or die("Could not
execute query");
        $mysql_fetch    = list($attachment_id,$attachment_name,$attachment_data) =
mysql_fetch_row($mysql_result) or die("Could not get results from mysql");

// Get the mimetype for this file
        $mysql_substr   = strrpos($attachment_name, ".");
        $mysql_ext              = substr($attachment_name, $mysql_substr + 1);
        $mysql_sql              = "select mimetypes_contenttype,mimetypes_extension 
from
system_mimetypes where mimetypes_extension = '$mysql_ext'";
        $mysql_result   = mysql_query($mysql_sql,$mysql_connect) or die("Could not
get extension content-type");
        $mysql_fetch    = list($contenttype,$extension) =
mysql_fetch_row($mysql_result) or die("Could not query db");

// Start sending the headers to the client so that he will either be able to
run/view the file or download it #file/octet-stream
        header ("Content-Type: $contenttype");
        header ("Content-Disposition: attachment; filename=\"" . $attachment_name .
"\"");

        echo $attachment_data;

        mysql_close($mysql_connect);
?>


Problem is,

SCENARIO 1:
  User click on link
  User click on save
RESULT:
  Internet Explorer tries to save the page which contained the html href
link

SCENARIO 2:
  User click on open (A new save/open dialog appears)
  User clicks on save
RESULT:
  Internet explorer saves the file with it's correct filename

SCENARIO 3:
  User clicks on open (A new save/open dialog appears)
  User clicks on open
RESULT:
  File is correctly opened


Now, it seems like Internet Explorer really wants me to click open once
before actually choosing either to open or save it..

Does anyone know how to solve this problem, I don't want the users to have
to figure out this "workaround" by themselves...

// Mattias


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to