473,789 Members | 2,544 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 #1
14 2200
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the filename
from the database.
"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 #2
But how do I output the file as my_vacation_pic .jpg when the actual filename
stored on the server is 0AX120S.jpg

1)the user clicks this link
http://mywebsite.com/download.aspx?file=003
2)download.aspx fetch index 003 from database
3)outputs 0AX120S.jpg as my_vacation_pic .jpg
4)the user only knows that hes downloading my_vacation_pic .jpg

Why do I want to do this? well, the user can upload files to my server and i
want them to be downloadable only through the download.aspx script. It also
helps protect the server against malicious scripts that people upload.

Thanks


"Tampa.NET Koder" <an*******@micr osoft.com> wrote in message
news:ub******** ******@TK2MSFTN GP10.phx.gbl...
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the
filename from the database.
"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 #3
On Sat, 19 Feb 2005 12:55:54 -0700, "Aaron" <ku*****@yahoo. com> wrote:
But how do I output the file as my_vacation_pic .jpg when the actual filename
stored on the server is 0AX120S.jpg


Hi Aaron:

One way to do this is to use set the src attribute of an image tag to
an ASPX page, and have the ASPX page determine the correct filename to
use and write the jpeg contents back into the response.

Here is an example:
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

Hope this helps,

--
Scott
http://www.OdeToCode.com/blogs/scott/
Jul 21 '05 #4
Well,
If you display the image to them and they right click on it and let say,
view the properties. Thie image 0AX120S.jpg will not display. They will
see this as the image source http://mywebsite.com/download.aspx?file=003.
If they choose to save your image to disk, then I think they will be able to
call it whatever you want. Hope this helps, otherwise see if anyone else
have a take on this

"Aaron" <ku*****@yahoo. com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
But how do I output the file as my_vacation_pic .jpg when the actual
filename stored on the server is 0AX120S.jpg

1)the user clicks this link
http://mywebsite.com/download.aspx?file=003
2)download.aspx fetch index 003 from database
3)outputs 0AX120S.jpg as my_vacation_pic .jpg
4)the user only knows that hes downloading my_vacation_pic .jpg

Why do I want to do this? well, the user can upload files to my server and
i want them to be downloadable only through the download.aspx script. It
also helps protect the server against malicious scripts that people
upload.

Thanks


"Tampa.NET Koder" <an*******@micr osoft.com> wrote in message
news:ub******** ******@TK2MSFTN GP10.phx.gbl...
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the
filename from the database.
"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 #5
Thanks but I not just dealing with image files, also zip, rar, pdf..., that
was just an example.

"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:pc******** *************** *********@4ax.c om...
On Sat, 19 Feb 2005 12:55:54 -0700, "Aaron" <ku*****@yahoo. com> wrote:
But how do I output the file as my_vacation_pic .jpg when the actual
filename
stored on the server is 0AX120S.jpg


Hi Aaron:

One way to do this is to use set the src attribute of an image tag to
an ASPX page, and have the ASPX page determine the correct filename to
use and write the jpeg contents back into the response.

Here is an example:
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

Hope this helps,

--
Scott
http://www.OdeToCode.com/blogs/scott/

Jul 21 '05 #6
With your method someone can still figure out the actual location by using a
packet sniffer. It just redirects to that location.
ie. http://mywebsite.com/download.aspx?file=003 redirects to
http://mywebsite.com/uploadedFiles/0AX120S.zip

I want this
http://mywebsite.com/download.aspx?file=003 gets
http://mywebsite.com/uploadedFiles/0AX120S.zip outputs as
http://mywebsite.com/uploadedFiles/my_vacation_pic.zip
If they type http://mywebsite.com/uploadedFiles/my_vacation_pic.zip in their
browser they will get a 404 error. There's no way for them knowing
http://mywebsite.com/uploadedFiles/0AX120S.zip because that address is not
sent to their computer.

Is this possible??
"Tampa.NET Koder" <an*******@micr osoft.com> wrote in message
news:OD******** ******@TK2MSFTN GP10.phx.gbl...
Well,
If you display the image to them and they right click on it and let say,
view the properties. Thie image 0AX120S.jpg will not display. They will
see this as the image source http://mywebsite.com/download.aspx?file=003.
If they choose to save your image to disk, then I think they will be able
to call it whatever you want. Hope this helps, otherwise see if anyone
else have a take on this

"Aaron" <ku*****@yahoo. com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
But how do I output the file as my_vacation_pic .jpg when the actual
filename stored on the server is 0AX120S.jpg

1)the user clicks this link
http://mywebsite.com/download.aspx?file=003
2)download.aspx fetch index 003 from database
3)outputs 0AX120S.jpg as my_vacation_pic .jpg
4)the user only knows that hes downloading my_vacation_pic .jpg

Why do I want to do this? well, the user can upload files to my server
and i want them to be downloadable only through the download.aspx script.
It also helps protect the server against malicious scripts that people
upload.

Thanks


"Tampa.NET Koder" <an*******@micr osoft.com> wrote in message
news:ub******** ******@TK2MSFTN GP10.phx.gbl...
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the
filename from the database.
"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 #7
On 19 Feb 2005, "Aaron" <ku*****@yahoo. com> postulated in news:
#G************* *@tk2msftngp13. phx.gbl:
Thanks but I not just dealing with image files, also zip, rar, pdf..., that was just an example.

"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:pc******** *************** *********@4ax.c om...
On Sat, 19 Feb 2005 12:55:54 -0700, "Aaron" <ku*****@yahoo. com> wrote:
But how do I output the file as my_vacation_pic .jpg when the actualfilename
stored on the server is 0AX120S.jpg


Hi Aaron:

One way to do this is to use set the src attribute of an image tag to an ASPX page, and have the ASPX page determine the correct filename to use and write the jpeg contents back into the response.

Here is an example:
http://msdn.microsoft.com/msdnmag/is...dge/default.as
px
Hope this helps,

--
Scott
http://www.OdeToCode.com/blogs/scott/



I hate it when clients do that!

Is it fun to change the requirement after the problem is solved? Why
not state the problem clearly next time so the answer fits the
problem by design instead of by accident?

Actually, with a little imagination this particular solution can be
adapted to any of the file types mentioned, or to solve it in
general, you could send an anonymous stream to the response object
based on the input file: read from source file, output to stream.

-- ipgrunt

Jul 21 '05 #8
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 #9
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 #10

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

Similar topics

5
2757
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
3063
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
2006
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
2963
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
2735
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
4192
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
1613
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
9663
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
10404
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
10195
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
9979
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...
0
9016
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
6765
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
5415
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
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2906
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.