lonewolf277 Posted October 27, 2006 Share Posted October 27, 2006 Hey everybody, not sure if this should go into the HTML help section, or maybe even in the database section under MySQL, but I'm using PHP code, so I thought I'd try here first. Sorry if it's a mis-post! ;)I'm having a problem with using headers to allow a user to save a file which is stored as a blob in a database [MySQL]. Specifically, when the user clicks on a link to the file, I have a 'getFile.php' file which gets the data from the database, and sends it to the user, using headers [code below]. The problem is, if the user selects "Open", then the file isn't displayed, something about how the "path or file name is invalid". Even more interestingly, the problem only seems to exist in IE, and the PHP works fine in Firefox!Here is the code snippet [runs when the user clicks on the link for a file]:[code]// $content_type is something like 'application/vnd.ms-powerpoint'...// $file_name is usually 'presentation.ppt'...// $length is just the file length, in bytes...// $file is the file data, taken from the blob in the DB...header ("Content-type: " . $content_type);header ("Content-Disposition: attachment; filename=" . $file_name);header ("Content-length: " . $length);echo $file;exit();[/code]Has anyone experienced anything like this before? I've tried searching for hours with no luck! Thanks in advance for any help anyone can give me!A side note: someone just suggested to me that perhaps IE doesn't completely load the file before it tries to open it in the associated program. Not sure if that helps... ??? Quote Link to comment Share on other sites More sharing options...
lonewolf277 Posted October 27, 2006 Author Share Posted October 27, 2006 Well, seemed to figure it out myself, so here's my solution to anyone who might be having the same sort of problem:[code]// $content_type is something like 'application/vnd.ms-powerpoint'...// $file_name is usually 'presentation.ppt'...// $length is just the file length, in bytes...// $file is the file data, taken from the blob in the DB...header ("Content-type: " . $content_type);// this line was changed...//header ("Content-Disposition: attachment; filename=" . $file_name);// to this...header ("content-Disposition: inline; filename=" . $file_name);header ("Content-length: " . $length);echo $file;exit();[/code]Hope this helps! 8) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.