http://coldfusion.com logo
Title
d

Dave Merrill

05/24/2023, 9:24 PM
How can I offer an Excel download (content built by cf) that asks the user for the filename and location to save? I've used this:
<cfcontent type="application/msexcel" reset="yes"><cfheader name="Content-Disposition" value="attachment; filename=#fileName#"><cfoutput>#reportData#</cfoutput><cfabort>
But in current Chrome it just saves with that filename, in the user's default Downloads directory. Content-Disposition value of attachment or inline acts the same. If I don't pass a filename it uses the URL filename. Have the gods of internet decided that a user-selectable file name and location is no longer a thing? Am I missing something obvious?
r

rstewart

05/24/2023, 9:28 PM
where the downloaded file gets saved and whether the user gets prompted for location including filename is almost certainly a configuration setting in the user’s browser. most give the user the ability to always be asked for a location or just save it in a default location (e.g,. desktop or a downloads folder).
From my Chrome settings:
d

Dave Merrill

05/25/2023, 1:05 AM
Hmmm, you're probably right. Semi-great for making this sort of thing make sense to users.
a

Adam Cameron

05/25/2023, 3:13 PM
It would be a gaping security flaw to not make the location of file downloads the decision of the user. Even "always to download dir, don't ask me" is their decision.
d

Dave Merrill

05/25/2023, 4:08 PM
Would be nice to let them name the file themselves though.
a

Adam Cameron

05/25/2023, 4:26 PM
They have their browser set to not be bothered with such questions. That's their choice. If they don't want to do that, that's up to them. If they do want to do that: that is also up to them.