Click here to Skip to main content
11,920,211 members (47,625 online)
Rate this:
Please Sign up or sign in to vote.
See more: image
How to save file path using fileupload control in SQL server database using ASP.NET and vb language.
i am using fileupload controls, when i am storing the images in a database the total path is not saved.
cmd.Parameters.Add(@Image_Path) = fileupload1.Filename

[Edit]Code block added[/Edit]
Posted 17-Feb-13 7:40am
Edited 17-Feb-13 7:45am
Sergey Alexandrovich Kryukov 17-Feb-13 12:59pm
Why? Is it the path on client or server-side file system?
Hend Riad 17-Feb-13 15:59pm
what is the datatype of the variable you store the path in it ?
Farzanatayeb 20-Feb-13 1:35am
Datatype is varchar(50) and column name is ImagePath

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is what you can get:
string path = FileUpload1.PostedFile.FileName 
AFAIR, recent browsers do not pass on the full filepath any more because of security reasons.

Have a look at the following discussions on similar topic:
FileUpload loses directory path.[^]
FileUpload.PostedFile.FileName not giving full path in chrome[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 455
1 phil.o 170
2 CPallini 150
4 F-ES Sitecore 130
0 OriginalGriff 6,778
1 KrunalRohit 4,495
2 Sergey Alexandrovich Kryukov 3,153
3 George Jonsson 2,810
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web04 | 2.8.151120.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100