473,805 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Cont ent-Disposition", "attachment ; filename=MyFile .xls")
AddHeader("Cont ent-type", "applicatio n/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=\subfo lder\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 1776
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**********@c omcast.netwrote in message
news:bq******** *************** *********@4ax.c om...
>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("Cont ent-Disposition", "attachment ; filename=MyFile .xls")
AddHeader("Cont ent-type", "applicatio n/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=\subfo lder\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.orgwro te:
>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=\XLSFi les\MyFile.xls
Or filename=.\XLSF iles\MyFile.xls
Or filename=..\XLS Files\MyFile.xl s
Or filename=\XLSFi les/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**********@c omcast.netwrote in message
news:f6******** *************** *********@4ax.c om...
On Tue, 31 Jul 2007 17:52:05 +0300, "Eliyahu Goldin"
<RE************ **************@ mMvVpPsS.orgwro te:
>>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=\XLSFi les\MyFile.xls
Or filename=.\XLSF iles\MyFile.xls
Or filename=..\XLS Files\MyFile.xl s
Or filename=\XLSFi les/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**********@c omcast.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("Cont ent-Disposition", "attachment ; filename=MyFile .xls")
AddHeader("Cont ent-type", "applicatio n/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=\subfo lder\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**********@c omcast.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("Con tent-Disposition", "attachment ; filename=MyFile .xls")
AddHeader("Con tent-type", "applicatio n/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=\subf older\MyFile.xl s 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.WriteF ile 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**********@c omcast.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**********@c omcast.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("Co ntent-Disposition", "attachment ; filename=MyFile .xls")
AddHeader("Co ntent-type", "applicatio n/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=\sub folder\MyFile.x ls 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
3231
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 work in progress (current release version is 0.4.6), but you should get a very good idea of what it's about by visiting the site (which uses it, funnily enough), or downloading a copy of it and trying it out.
0
2330
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 (current release version is 0.4.8), but you should get a very good idea of what it's about by visiting the site (which uses it, funnily enough), or downloading a copy of it and trying it out.
0
2145
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: http://www.rockley.com/workshops.htm The Rockley Group Content Management Workshop Series is designed to
14
2167
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 <!--/tag:3--> If I only wanted to see the contents of tag 2 for example, how could I strip out 1 and 3?
1
1557
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 menu which is working just fine. In column b I have two subdivisions. Top is for thumbnails, bottom is for description. What I am looking at doing, if possible, is to have the thumbnails and
10
2677
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 cross-browser support.for IE (5-6) and browsers derived from Mozilla (varies). Thank you... <%= Clinton Gallagher
7
8733
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 remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
0
2119
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 sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
1
2284
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 definitions, I got the impression that the rendered content is referring to the source document and not the particular
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.