Passing file names with spaces in them
I know nothing of PHP whatsoever. I'm attempting to use a script I obtained here on my Web site. It's not working quite the way I'd like it to.
In this discussion a PHP script was provided that forces downloads to occur rather than allowing the browser to open the file.
I'm happy with the script, but I like my files to have spaces in their names. When a client downloads a file, it will then have a more common "2013-04-01 deposition of Jack Sprat.pdf" name rather than "2013-04-01_deposition_of_Jack_Sprat.pdf." It's simply more natural to my end users to see the spaces.
Is there a way to modify the script to accept file names with spaces?
The script accepts file names with spaces if I include the download script in the same folder as the HTML and the file to be downloaded.
However, if the script is in a scripts folder, separate from the HTML and downloadable file, it cannot parse file names with spaces in them; the user downloads an error message. I can post that if that helps; I also don't want to overwhelm.
Or if the script and HTML are in a parent folder, with the downloadable file in a subfolder, the same error occurs if the file includes a space in its name.
Is there a way I can force download (rather than display) of files, using a single script called from any other page on my site, and still be able to distribute files with spaces in their names?
This is the PHP script I'm currently using:
Any help you're willing and able to offer will be gratefully accepted.
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
-- Timothy J. McGowan
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)