473,802 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rename file on download

On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(pri vacy
protection). When a visitor clicks on the link I want them to see
my_vacation_pic .jpg (fetch realname from database) is this possible with
ASP.NET(C#)?

Thanks

Aaron
Jul 21 '05
14 2202
All the uploaded files will be stored in a folder. Do you have an example on
how to set response headers in asp.net? I did a search the results only show
me how to get the request headers.
Also is this method compatible with older browsers? IE4 NS4?

Thanks,
Aaron
"Nick Malik [Microsoft]" <ni*******@hotm ail.nospam.com> wrote in message
news:ir******** ************@co mcast.com...
This exchange has been fun to watch!

Hi Aaron,

Clicking a link sends a request to the web server. The response that
comes back has a small set of HTTP headers associated with it.
In these headers, you can specify the filename that you want the browser
to use when opening the file.

Content-Type = application/download
Content-Disposition = attachment; filename=my_vac ation_pic.jpg

This will allow the user to save the file by the name you provide.

You simply have to code the headers.

I'm not clear from your messages if you are storing the files in the
database or just their names. If you are storing just their names, then
you will want your ASPX page to set the HTTP headers first, then read the
file into memory, encode to Base64, and stream it into the Response
object.

The browser will do the rest.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Aaron" <ku*****@yahoo. com> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
On my website I have a dynamic link(aspx) to this file
0AX120S.jpg(pri vacy protection). When a visitor clicks on the link I want
them to see my_vacation_pic .jpg (fetch realname from database) is this
possible with ASP.NET(C#)?

Thanks

Aaron


Jul 21 '05 #11
Thanks for the article. I'm experimenting with it right now. Don't know if
it work for my case. Since the files requested are not aspx files,
(zip,jpg,gif,pd f...)

Is global.asax responsible for all reqeusts made to the webapp or just the
asp.net ones?

"DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
news:ev******** ******@TK2MSFTN GP12.phx.gbl...
While I have never used it so I don't know if it is an answer to your
question for sure, when I read your question, I immediately thought of
articles I have read on the HttpContext.Rew ritePath method.

http://www.aspnetpro.com/NewsletterA...200309pj_l.asp

DalePres
MCAD, MCDBA, MCSE

"Aaron" <ku*****@yahoo. com> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
On my website I have a dynamic link(aspx) to this file
0AX120S.jpg(pri vacy protection). When a visitor clicks on the link I want
them to see my_vacation_pic .jpg (fetch realname from database) is this
possible with ASP.NET(C#)?

Thanks

Aaron


Jul 21 '05 #12
This works with IE4.01. This will not work with IE5.0, but it will work
with IE5.1 and higher. Stats prove that no one is using IE4 or NS4 anymore.
(If that's your market, then you are already out of business). I haven't
tested with Opera and Firefox, but that shouldn't be difficult to test with.
Word on the street is that those browsers are pretty darn good, so I
wouldn't expect any issues.

You need HTTPResponse.Ap pendHeader
http://msdn.microsoft.com/library/en...eadertopic.asp

An article that can help
http://aspalliance.com/articleViewer...aId=259&pId=-1

I picked these off of google

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Aaron" <ku*****@yahoo. com> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
All the uploaded files will be stored in a folder. Do you have an example
on how to set response headers in asp.net? I did a search the results only
show me how to get the request headers.
Also is this method compatible with older browsers? IE4 NS4?

Thanks,
Aaron
"Nick Malik [Microsoft]" <ni*******@hotm ail.nospam.com> wrote in message
news:ir******** ************@co mcast.com...
This exchange has been fun to watch!

Hi Aaron,

Clicking a link sends a request to the web server. The response that
comes back has a small set of HTTP headers associated with it.
In these headers, you can specify the filename that you want the browser
to use when opening the file.

Content-Type = application/download
Content-Disposition = attachment; filename=my_vac ation_pic.jpg

This will allow the user to save the file by the name you provide.

You simply have to code the headers.

I'm not clear from your messages if you are storing the files in the
database or just their names. If you are storing just their names, then
you will want your ASPX page to set the HTTP headers first, then read the
file into memory, encode to Base64, and stream it into the Response
object.

The browser will do the rest.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Aaron" <ku*****@yahoo. com> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
On my website I have a dynamic link(aspx) to this file
0AX120S.jpg(pri vacy protection). When a visitor clicks on the link I
want them to see my_vacation_pic .jpg (fetch realname from database) is
this possible with ASP.NET(C#)?

Thanks

Aaron



Jul 21 '05 #13
Aaron,

The way that I think that I would probably do your problem.
I would create in my database from every picture a thumbnail that I would
present on a imagebutton on my page

I would set reference number in a tag and that with the used paths in a
dataset that I would store in a session.

When the button is clicked I would get the image and translate that to a
bitmap.

That bitmap I would send using the response.redire ct(bitmap)

Than the user would never know the original path.

Just an idea

Cor
Jul 21 '05 #14
You can, but it requires you to add new Application Mappings in IIS, then
you must program a DLL to do the actual job for you, in your case the DLL
would probably look up the file name from the database, and then HTTP
redirect the user to a download page where the user will start to download
the file.

-Inge

"Aaron" <ku*****@yahoo. com> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(pri vacy
protection). When a visitor clicks on the link I want them to see
my_vacation_pic .jpg (fetch realname from database) is this possible with
ASP.NET(C#)?

Thanks

Aaron



Jul 21 '05 #15

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

Similar topics

5
2758
by: jez123456 | last post by:
Hi, I’ve written a c# program to compact certain msaccess databases. The way this works is to compact say C:\test1.mdb to C:\temp.mdb, then delete C:\test1.mdb and rename C:\temp.mdb as C:\test1.mdb. My problem occurs if there is already a C:\temp.mdb file. I don’t want to just delete this, as it could have been created separately by a user. In my code, I set a constant as follows: private const string tempMdb = @"C:\temp.mdb";
14
3064
by: Aaron | last post by:
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy protection). When a visitor clicks on the link I want them to see my_vacation_pic.jpg (fetch realname from database) is this possible with ASP.NET(C#)? Thanks Aaron
1
2009
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type and renames them using the "Rename(oldfilename,newfilename)" function. Unfortunately, this function only seems to work if and only if it is preceeded by a 'msgbox("<some text>")'. ie. If I have the following the service sees the file
2
2967
by: Bruce Russell | last post by:
This may sound stupid but I can't rename the WebForm1.aspx in the solution explorer. The file is located in my local web server at C:\Inetpub\wwwroot\Lab3-VB-Starter\WebForm1.aspx Is there some configuration problem in my IIS setup? Thanks,
5
2736
by: Tony Meyer | last post by:
On Windows, if I do os.rename(old, new) where old is a file that is in-use (e.g. python itself, or a dll that is loaded), I would expect that an error would be raised (e.g. as when os.remove is called with an in-use file). However, what happens is that a copy of the file is made, and the old file still exists. For example: C:\>c:\python24\python.exe Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32
4
2207
by: Dynamo | last post by:
I am trying to upload a file and then rename the file as something else. Everything worked fine unless the renamed filename already existed. So I added some extra code to check if the filename already existed and if so to delete it before renaming the uploaded file. Everything now works fine in the following code: $uploaddir = 'images/'; $uploadfile = $uploaddir . basename($_FILES); echo '<pre>'; if (move_uploaded_file($_FILES,...
1
4194
by: googlegroups | last post by:
I have a standard template file that is available for download (currently just an anchor tag). I would like to rename the file that is sent to the client (to include an ID used by the template) so if the user saves the file rather than opens it, it will have the necessary info to work properly when it is opened. Is there a means via javascript to rename the file being downloaded? Thanks very much!
2
1615
by: shapper | last post by:
Hello, I want to make a file available to a user for download on an ASP.NET page. So I need to have a button that when clicked, the file is download. However, before the file is downloaded, I want it to be renamed so the file name that the users gets is different that the one in the server. The extension will be the same. Any idea of how to do this?
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10309
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...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
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
5496
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.