When I download a private file like
http://mydomain.com/?q=system/files/test.pdf
It downloads okay but
the browser does not know the name of the file.
ie gives the file the name "mydomain.com" and firefox gives it a password like name.

I seem to remeber it working okay before.

Any ideas on what happened?

Thanks, russ

Comments

ChrisOwens’s picture

I am having the same experience.

This is an existing, issue, see http://drupal.org/node/82614

looking in modules/upload/upload.module, around line 270, I tried the temporary expedient of adding

'Content-Disposition: attachment; filename="'. $file->filename .'"'

That solves the problem for the one case I was playing with, but I have no idea if this is the right place to do it, or if it beaks anything else.

francoud’s picture

I have the same problem: with drupal 5.6 and I.E. For me, it was with .zip files: i.e. didnt understand the real filename, it downloaded with an incorrect name and then wasn't able to find it.

I solved it (for me, at least) patching upload.module, adding your line and another one:

'Content-Disposition: '. $disposition .'; filename='. $file->filename,
'Expires: 0', 'Pragma: cache', 'Cache-Control: private',

Now upload.module at around line 270 should be (it works for me):

return array(
'Content-Type: '. $type,
'Content-Length: '. $file->filesize,
'Content-Disposition: '. $disposition .'; filename='. $file->filename,
'Expires: 0', 'Pragma: cache', 'Cache-Control: private',
);

Would you believe...? :

1) the problem was present in older versions of drupal (4.7.something) - at that time, I had to apply this patch:
http://drupal.org/node/81123#comment-162687 (note it's slightly different from today's one)

2) it was solved I think with drupal 4.7.6 (the "expires: 0" line was present in upload.module and, as far as I can remember,
with drupal 4.7.6 it worked).

I wonder when the "expires:0, pragma:cache" line has been lost between 4.7.6 and 5.6.... :-/

terryallan’s picture

Has this a fix yet for Drupal v5? Download in any browser as far as I can see changes file name of attachment to 'mydomain.extension'

It isn't a problem other than the file name is changed.

Lios’s picture

You saved my life! This works like a charm. I've searched for days to find out what the problem was :)