473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

controlling a downloaded filename

Can I control the name of a file downloaded if that file name isn't in a
request header?
I have a data grid that contains a list of excel files by date. In each row
there is a ButtonColumn pointed at a handler containing the code:

case "Download":
Response.ContentType = "Application/x-msexcel";
Response.TransmitFile(e.Item.Cells[0].Text);
Response.End();
break;

It works, but the filename offered to the client is always the name of the
aspx file with the extension replaced with .xls. Can I make the name of the
xls file offered to the client the same as it is on the server?

It seems like it should be simple enough to do but I've been searching for
the correct method, property, header without success.

Thanks,
bob


Nov 19 '05 #1
2 1177
hi bob
i use this in my script

Response.AddHeader "content-disposition", _
"attachment; filename=""" & strFileName & """"

Bob Weiner wrote:
Can I control the name of a file downloaded if that file name isn't in a
request header?
I have a data grid that contains a list of excel files by date. In each row
there is a ButtonColumn pointed at a handler containing the code:

case "Download":
Response.ContentType = "Application/x-msexcel";
Response.TransmitFile(e.Item.Cells[0].Text);
Response.End();
break;

It works, but the filename offered to the client is always the name of the
aspx file with the extension replaced with .xls. Can I make the name of the
xls file offered to the client the same as it is on the server?

It seems like it should be simple enough to do but I've been searching for
the correct method, property, header without success.

Thanks,
bob

Nov 19 '05 #2
thanks. works like a champ!

bob
"dave bray" <da******@brayworth.com.australia> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
hi bob
i use this in my script

Response.AddHeader "content-disposition", _
"attachment; filename=""" & strFileName & """"

Bob Weiner wrote:
Can I control the name of a file downloaded if that file name isn't in a
request header?
I have a data grid that contains a list of excel files by date. In each
row there is a ButtonColumn pointed at a handler containing the code:

case "Download":
Response.ContentType = "Application/x-msexcel";
Response.TransmitFile(e.Item.Cells[0].Text);
Response.End();
break;

It works, but the filename offered to the client is always the name of
the aspx file with the extension replaced with .xls. Can I make the name
of the xls file offered to the client the same as it is on the server?

It seems like it should be simple enough to do but I've been searching
for the correct method, property, header without success.

Thanks,
bob


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joshua | last post by:
Is there a way to set up Apache to invoke a PHP equest when a file (a image for example) is downloaded? Say, then, that http://www.foo.com/downloads/app1.zip is downloaded, Id like to have...
21
by: Cigar | last post by:
I am developing a program for a client. She runs a shop where her clients bring in items for sale or short term buyback. Development of the program has been going great but she's mentioned that...
12
by: Rob Nicholson | last post by:
We've implemented functionality to allow a user to download a document (any document type) from the IIS server using the following code: Response.Clear() Response.ContentType =...
3
by: Loane Sharp | last post by:
Hi there I use the FileStream object to download a zip file over the internet to my local disk. The file downloads successfully, but when I attempt to unzip it, I'm told that the file is in use...
2
by: comp.lang.php | last post by:
class ReportGenerator { function ReportGenerator() {} /** * Generate the HTTP headers necessary for this file type. Can be called statically *
3
by: Bouffa | last post by:
Hello everyone, I suppose you all know force-download scripts. The problem is that these scripts don't allow files to be splitted when downloading them via a download manager. I've found a...
11
by: Hendri Adriaens | last post by:
Hi, I use the following code to offer a download: header("Content-Type:$mimetype"); header("Content-Disposition: attachment; filename=$filename");...
1
by: Rajaaa | last post by:
Hello Everyone, While i'm downloading a file it will correctly downloaded but contents of .doc file is doesn't display,but if i open .txt file that content has been displaying. <?php...
7
by: xhunter | last post by:
ok here is my problem, I am trying to change the source file of the mediplayer using javascript, my script works perfectly in "Internet Explorer", but no matter what I do, it doesn't work in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.