473,396 Members | 1,895 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,396 software developers and data experts.

Content-Disposition attatchment question

I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?
Jul 31 '07 #1
6 1755
The name should be relative to your server application root.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Martin" <ma**********@comcast.netwrote in message
news:bq********************************@4ax.com...
>I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?

Jul 31 '07 #2
On Tue, 31 Jul 2007 17:52:05 +0300, "Eliyahu Goldin"
<RE**************************@mMvVpPsS.orgwrote:
>The name should be relative to your server application root.
That's what I'm doing. I created a sub-folder named XLSFiles in the
server root. That's where I'm creating the xls files.

Can you give me an example of the exact syntax to use?

Is it filename=\XLSFiles\MyFile.xls
Or filename=.\XLSFiles\MyFile.xls
Or filename=..\XLSFiles\MyFile.xls
Or filename=\XLSFiles/MyFile.xls
Or ...

I've tried everything I can think of - nothing works.
Jul 31 '07 #3
It should be server application root, off the application virtual directory.

And the path will be

XLSFiles/MyFile.xls

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Martin" <ma**********@comcast.netwrote in message
news:f6********************************@4ax.com...
On Tue, 31 Jul 2007 17:52:05 +0300, "Eliyahu Goldin"
<RE**************************@mMvVpPsS.orgwrote:
>>The name should be relative to your server application root.

That's what I'm doing. I created a sub-folder named XLSFiles in the
server root. That's where I'm creating the xls files.

Can you give me an example of the exact syntax to use?

Is it filename=\XLSFiles\MyFile.xls
Or filename=.\XLSFiles\MyFile.xls
Or filename=..\XLSFiles\MyFile.xls
Or filename=\XLSFiles/MyFile.xls
Or ...

I've tried everything I can think of - nothing works.


Jul 31 '07 #4
IMO it could be unrelated. Content-disposition just suggests a name for the
downloaded file (it doesn't even have to be an existing file).

For now it's a bit unclear but it would make me rather think that the
problem is in the code that streams the file to the browser. This is where
the updated location should be taken into account.

---
Patrice

"Martin" <ma**********@comcast.neta écrit dans le message de news:
bq********************************@4ax.com...
>I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?

Jul 31 '07 #5
I agree with what you're saying. Do you have any idea as to how I
would get the server to use a different location? It seems to be able
to find the created file only if I put it in the server's application
root directory.

I tried creating a virtual directory named XLSFiles but that made no
difference.

On Tue, 31 Jul 2007 17:41:52 +0200, "Patrice"
<http://www.chez.com/scribe/wrote:
>IMO it could be unrelated. Content-disposition just suggests a name for the
downloaded file (it doesn't even have to be an existing file).

For now it's a bit unclear but it would make me rather think that the
problem is in the code that streams the file to the browser. This is where
the updated location should be taken into account.

---
Patrice

"Martin" <ma**********@comcast.neta écrit dans le message de news:
bq********************************@4ax.com...
>>I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?
Aug 2 '07 #6
If this is a virtual directory you'll have to user Server.MapPath to
transform this location into a physical server side directory. Using the
full absolute path of the file you can then use Response.WriteFile to stream
the file from this location .

For now you could just stream a sample text file directly to the browser
wihtout the content disposition header so that you can see whatever happens
includiong a possible error. Also try first to write down just the file
location so that you can check the absolute path is correct...

For now I would say that the file location is not correctly created
resulting in not finding the file...

--
Patrice

"Martin" <ma**********@comcast.neta écrit dans le message de news:
78********************************@4ax.com...
>I agree with what you're saying. Do you have any idea as to how I
would get the server to use a different location? It seems to be able
to find the created file only if I put it in the server's application
root directory.

I tried creating a virtual directory named XLSFiles but that made no
difference.

On Tue, 31 Jul 2007 17:41:52 +0200, "Patrice"
<http://www.chez.com/scribe/wrote:
>>IMO it could be unrelated. Content-disposition just suggests a name for
the
downloaded file (it doesn't even have to be an existing file).

For now it's a bit unclear but it would make me rather think that the
problem is in the code that streams the file to the browser. This is where
the updated location should be taken into account.

---
Patrice

"Martin" <ma**********@comcast.neta écrit dans le message de news:
bq********************************@4ax.com...
>>>I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?

Aug 3 '07 #7

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

Similar topics

12
by: jonathan.beckett | last post by:
Hi All, For the past few months I have been working on an open source Apache/PHP/MySQL content management system - and have recently made it available for download. It's still very much a...
0
by: jonathan.beckett | last post by:
Hi All, I have just made version 0.4.8 of the PluggedOut CMS Content Management System available for download - it's free, and covered by the GPL. It's still very much a work in progress...
0
by: Scott Abel | last post by:
For immediate release: The Rockley Group Content Management Workshop Series Coming to Atlanta, Seattle, Vancouver, Chicago, Washington, DC, Toronto, and Research Triangle Park Learn more:...
14
by: j1c | last post by:
How can I remove the content in between tags? I have a page that has several custom tags: <!--tag:1--> Content 1 <!--/tag:1--> <br> <!--tag:2--> Content 2 <!--/tag:2--> <br> <!--tag:3--> Content 3...
1
by: Richard | last post by:
http://dynamicdrive.com/dynamicindex5/linkinfo.htm Using the above script, I have a plan whereby when the main link is active, two different content swaps take place. Column A shows the main...
10
by: clintonG | last post by:
Can somebody direct me to documents or source that supports the use of collapsible content that is collapsed by default when the page is loaded? The secondary objective would of course be...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
1
by: dave8421 | last post by:
Hi, I'm trying to make sense of the definition for "Rendered Content" in current CR for CSS 2.1 Is rendered content what is displayed on the particular media or device? from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.