file download issues
Posted: Thu Aug 24, 2006 1:32 pm
Greets,
I'm having problems delivering consistent file name to the user that's attempting to download it.
Here's is the issue.
For example. I have file called
this is my file.doc
I can't force it to download exaclty the way it is, in this case with spaces between the words. If I try to force download, it will just offer to download file
"this" with no extention or anything. Just the first word.
I tried using rawurlencode and urlencode but in each case I'd end up with
rawurlencode => this%20is%20my%20file.doc or
urlencode => this+is+my+file.doc
I'm not sure if I'm missing something.
Greatly appreciated
dubja teeff
I'm having problems delivering consistent file name to the user that's attempting to download it.
Here's is the issue.
For example. I have file called
this is my file.doc
I can't force it to download exaclty the way it is, in this case with spaces between the words. If I try to force download, it will just offer to download file
"this" with no extention or anything. Just the first word.
I tried using rawurlencode and urlencode but in each case I'd end up with
rawurlencode => this%20is%20my%20file.doc or
urlencode => this+is+my+file.doc
I'm not sure if I'm missing something.
Code: Select all
/**
* [filename] => Project_Profile[1].doc
* [filepath] => 63.1156438918
*/
$fpath = '/var/www/gcs/documents/' . $document['filepath'];
$fname = $document['filename'];
$fsize = $document['size'];
$buffer_size = 1024;
header('HTTP/1.1 200 OK');
header('Content-Length: ' . $fsize);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename=' . $fname);
header('Content-Transfer-Encoding: binary');
if(file_exists( $fpath ) && $fh = fopen( $fpath, 'rb' ) )
{
while( $buffer = fread( $fh, $buffer_size ) )
{
echo $buffer;
}
fclose( $fh );
}Greatly appreciated
dubja teeff