Retrieve filename

Posted by Nishithraj under Regular Expressions on 1/15/2010 | Views : 1376 | Status : [Member] | Replies : 6
I have the following code to save a file

Response.ContentType = strFileName;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName);

Response.TransmitFile(strUpdPath+strFileName);

Response.End();


Here usercan specify any name at runtime while saving the file. I would like to retrive the filename after user saving the file.

Any options are available to get that??

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan



Responses

Posted by: Vuyiswamb on: 1/15/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
but the strFileName is supposed to carry the File name , am i missing something ?


Thank you for posting at Dotnetfunda
[Administrator]

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 1/15/2010 [Member] Bronze

Up
0
Down
Vuyiswamb

Actually the name provided in the string strFileName will be displayed in the save dialog box by default to the user.

Later on he can chang it.

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 1/15/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
I Dont understand your problem. Can you explain better?

Thank you posting at dotnetfunda

Vuyiswa Maseko



Thank you for posting at Dotnetfunda
[Administrator]

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mehulthakkar1 on: 1/18/2010 [Member] Starter

Up
0
Down
File name provided by you will be displayed to end user. but end user can change the file name from his side. you won't be able to retrieve that name once it will be changed and saved.

Thanks

Mehul Thakkar

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rtpharry on: 1/18/2010 [Member] [MVP] Bronze

Up
0
Down
Hi,

You cannot detect what the filename the user saved the file with after your TransmitFile() call.

Also you may have a security vulnerability. Where have you get the value for "strUpdPath" from?

If that comes from a querystring or user entered data then you are exposing yourself to the user typing in ..\ to access areas outside of where you think you are giving them access such as ..\web.config - then they have your database passwords!

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rtpharry on: 1/18/2010 [Member] [MVP] Bronze

Up
0
Down
Also I just wanted to suggest the follow method which is part of .net:

System.IO.Path.Combine()

It is specifically designed for joining multiple parts of paths together.

http://msdn.microsoft.com/en-us/library/fyy7a5kt.aspx

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response