Asp.net Upload File Hasfile Always False

  1. Asp Net Core Upload File
  2. Asp.net File Upload
  3. Asp File Upload Code
  4. Asp Upload File To Server
  1. Re: FileUpload.HasFile is always false Mar 19, 2009 04:07 PM| jamesewelch| LINK I've tried coding it that way (it was the way that I initially started but when I ran into these problems, I tried to reduce the number of methods, functions, pointers, etc.).
  2. File Upload control HasFile always false, name is always Empty String, no update panel used. I have a Details View that has a file upload field in it. When I fill out the information and upload a file (I have tried multiple files ranging from 9k to 6.8MB) all of the information (text fields) submit fine, but the uploaded file is always returning a false when I check the HasFile and always returns String.Empty when I check the file name.

Then I check if myFileUploadControl.HasFile property to see if there exists a file and if there does upload the file then continue with the code. The issue is when I click this 'Update' button.HasFile always returns false even though I can see the text string of the path in the fileuploadcontrol textbox (the standard one next to the browse button).

Active1 month ago

I have a Details View that has a file upload field in it. When I fill out the information and upload a file (I have tried multiple files ranging from 9k to 6.8MB) all of the information (text fields) submit fine, but the uploaded file is always returning a false when I check the HasFile and always returns String.Empty when I check the file name.

Am I doing something wrong? The details view is in a Panel and Not an Update Panel

Asp net vb fileupload control

Code Behind:

EDITI added a Page_Load call and it looks as if the page is posting back when I click the Auto Generated Update Button for the DetailsView. This postback is probably clearing out my FileUpload field. Any ideas on how to get around it?

Edit #2 I have now put an update panel around the DetailsView and set the postback trigger the DetailsView (see below) and it still is not working, it seems to be clearing the upload control prior to submitting.

Gridview Code as requested

a few bound fields are after this (first name, last name, etc)

EvanGWatkins
EvanGWatkinsEvanGWatkins
8576 gold badges19 silver badges49 bronze badges

4 Answers

Asp.net upload file hasfile always false positive

Everyone, Thanks for all of the help but I figured it out. I had to set the Page.Form.Enctype = 'multipart/form-data.

Asp Net Core Upload File

Here is the code for it to work!

Asp.net File Upload

Simon Martin
3,0127 gold badges48 silver badges83 bronze badges
EvanGWatkinsEvanGWatkins
8576 gold badges19 silver badges49 bronze badges

I'm sorry if this is a dumb answer but I usually use on gridviews the selectedindexchanging to capture current row values. Have you tried that instead of the selectedindexchanged?

AndresAndres
1,2435 gold badges31 silver badges60 bronze badges

Asp File Upload Code

yapingchenyapingchen

Asp Upload File To Server

Make sure you only have one <form> on the same page.

Rami ZebianRami Zebian

Not the answer you're looking for? Browse other questions tagged asp.netfile-upload or ask your own question.