Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File upload in Form View & storing filename in DB

Status
Not open for further replies.

MustangPriMe

IS-IT--Management
Oct 9, 2002
74
GB
Hi all,

I have a form view on a page to amend a given record in the database. All the controls are bound to an Access data source.
The form view includes a file upload control to upload a PDF related to the record to the server.
Both the bound controls, and the file upload control are working perfectly.

However, as well as uploading the file, I need to store the filename in a field in the record as well.

What's the best/simplest way to acheive this?

Thanks in advance,
Paul
 
Do you call the upload yourself in code?
toss the filename into a variable during your processing, and then use that in your update.

Code:
//gets just the filename and its extension without the directories
strFileName = objFile.FileName;
strFileName = strFileName.Substring(strFileName.LastIndexOf(@"\") + 1);

objFile is an HttpPostedFile
 
Hi Adam,

Thanks for the response.
Sorry - re-reading my query, I wasn't clear enough in my question what the problem was. Saying that, I also wasn't aware of the "LastIndexOf" method, so that's given me a simpler way of getting the filename - thanks.

The query is how do I get that filename into the record that the FormView is using? Or do I need to run a 2nd query in code, updating the same record with the filename after the FormView has finished with it... Which is fine except if the FormView was in insert mode so I don't have the record ID...

Only been using .Net for a couple of weeks, so I can't quite see how all the pieces need to go together just yet!

Thanks
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top