Firstly, please show me as to how you would save the new file to a location?
Are you aware that webmatrix upload helper picks the true extension of the actual file and not what has been specified in the Request.File
That's why, if the extension of a file has been manually changed lets say from .jpg to .gif then Path.GetExtension(photo.FileName) woud be .gif But it really saves it with
.jpg
And then you would have a different name between what has been uploaded and what has been called in the database.
Member
107 Points
297 Posts
Save an image with a different name
Jul 03, 2013 09:17 PM|engcanada|LINK
I need to tottaly change the name of uploaded file but with its orginal extension.
The following won't do:
All-Star
52523 Points
15670 Posts
Re: Save an image with a different name
Jul 03, 2013 09:37 PM|oned_gk|LINK
Path.GetExtension(photo.FileName);
Suwandi - Non Graduate Programmer
Member
107 Points
297 Posts
Re: Save an image with a different name
Jul 03, 2013 09:53 PM|engcanada|LINK
Firstly, please show me as to how you would save the new file to a location?
Are you aware that webmatrix upload helper picks the true extension of the actual file and not what has been specified in the Request.File
That's why, if the extension of a file has been manually changed lets say from .jpg to .gif then Path.GetExtension(photo.FileName) woud be .gif But it really saves it with .jpg
And then you would have a different name between what has been uploaded and what has been called in the database.
Contributor
4010 Points
1926 Posts
Re: Save an image with a different name
Jul 07, 2013 11:35 AM|Afzaal.Ahmad.Zeeshan|LINK
Actually the code
Handles the name, so the extension is also provided in this! I mean if the file was
Then the FileName will have the value as "profile pic.png"
So writing the line as
Will let you have the Image file name as: 45ea4527-7ddd-4965-b9ca-c6444982b342_profile pic.png
If you don't get the required result, then there is a bug in your code, please check it twice!