Hi,
BACKGROUND:
I have built a web application for a client which allows them to save excel files to the server.
When I first built the application I stored these files in an uploads folder and linked to them directly from pages within the application (eg File).
On reflection this wasn't very secure so I changed the uploader file to store the files above the web root and thereby prevent direct access.
I deliver the files back to the user by way of a php 'retriever' file (eg File). The file (after some user authentication checks) looks like this:
header("Content-type: application/octet-stream");
$_file = $_GET['filename'];
$sPattern = '/\s*/m';
$sReplace = '';
$_strippedfile = preg_replace( $sPattern, $sReplace, $_file );
header("Content-Disposition: attachment; filename=".$_strippedfile."");
echo file_get_contents('/var/www/uploads/'.$_file);
PROBLEM:
The above all works fine unless the user chooses to 'open' rather than 'save' in internet explorer. Excel attempts to open the file and throws '...could not be found. Check the spelling of the file name, and verify that the file location is correct'.
I've googled that error and it appears that it's to do with the length of the filename (including the path). Unfortunately the path to temporary internet files is out of my control so was wondering if there was a way to force the user to save the file rather than open it? [Apparently this can be configured locally but a) my clients aren't very technical and b) because they're on a corporate network all admin rights are tied down.]
Any other ideas welcomed.