FileUpload control problems
Hey everyone,
I am using the FileUpload control and have noticed that if the user inputs garbage text into the file upload textbox, then I click my submit button which handles the upload, nothing happens. Is there some kind of validation I can do to check if the textbox has an incorrectly formatted path to the file, or just garbage text sitting in there!? I don't want users sitting there wondering why the submit button isn't doing anything if they've accidentally input something wrong!
[514 byte] By [
crash2006] at [2007-11-11 10:08:23]

# 1 Re: FileUpload control problems
There are a couple of options here. First you can check the PostedFile object of the control to see if it is Nothing. Second, you can also check the PostedFile.ContentLength value to see if it is zero.
# 2 Re: FileUpload control problems
Thanks for your response. However, my code isn't even entered when the Submit button is pressed if the textbox has an incorrectly formatted path to the file. So without it entering the code, I cannot do any of those checks. Do you possibly have a coding example of how the above is done?
I have my submit button checking if the length of the FileName is > 0, if so it enters my file upload method where it then proceeds to check if there is a valid file attached, etc. All that works fine, as long as it makes it into that method to start with, which it currently isn't only when the textbox has an incorrectly formatted path.
I'm at a loss! Thanks greatly for the help.