FileUpload.HasFile is always false
-
Hi, I have an asp.net web forms project. No master pages, no ajax, I have a file upload control and when I fire postback the HasFiles property is always empty. I started a new asp.net project. Copy/Pasted the code into it and it worked. HasFiles was retained. Does anyone know why? The code:
protected void Page_Init(object sender, EventArgs e)
{
if(IsPostBack) return;
}protected void Page_Load(object sender, EventArgs e)
{
if(flImage.HasFile){
Application["FileBytes"] = flImage.FileBytes;
Application["FileContent"] = flImage.FileContent;
Application["FileName"] = flImage.FileName;
Application["PostedFile"] = flImage.PostedFile;
}HasFile is always false.
-
Hi, I have an asp.net web forms project. No master pages, no ajax, I have a file upload control and when I fire postback the HasFiles property is always empty. I started a new asp.net project. Copy/Pasted the code into it and it worked. HasFiles was retained. Does anyone know why? The code:
protected void Page_Init(object sender, EventArgs e)
{
if(IsPostBack) return;
}protected void Page_Load(object sender, EventArgs e)
{
if(flImage.HasFile){
Application["FileBytes"] = flImage.FileBytes;
Application["FileContent"] = flImage.FileContent;
Application["FileName"] = flImage.FileName;
Application["PostedFile"] = flImage.PostedFile;
}HasFile is always false.
Whoops! Looks like you've broken the forum. Please edit your post and either remove or HTML-encode the
<table>
and other HTML tags in your question. The quickest option is to select the entire block of code and click the "code" button in the editor toolbar.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Hi, I have an asp.net web forms project. No master pages, no ajax, I have a file upload control and when I fire postback the HasFiles property is always empty. I started a new asp.net project. Copy/Pasted the code into it and it worked. HasFiles was retained. Does anyone know why? The code:
protected void Page_Init(object sender, EventArgs e)
{
if(IsPostBack) return;
}protected void Page_Load(object sender, EventArgs e)
{
if(flImage.HasFile){
Application["FileBytes"] = flImage.FileBytes;
Application["FileContent"] = flImage.FileContent;
Application["FileName"] = flImage.FileName;
Application["PostedFile"] = flImage.PostedFile;
}HasFile is always false.
-
Hi, I have an asp.net web forms project. No master pages, no ajax, I have a file upload control and when I fire postback the HasFiles property is always empty. I started a new asp.net project. Copy/Pasted the code into it and it worked. HasFiles was retained. Does anyone know why? The code:
protected void Page_Init(object sender, EventArgs e)
{
if(IsPostBack) return;
}protected void Page_Load(object sender, EventArgs e)
{
if(flImage.HasFile){
Application["FileBytes"] = flImage.FileBytes;
Application["FileContent"] = flImage.FileContent;
Application["FileName"] = flImage.FileName;
Application["PostedFile"] = flImage.PostedFile;
}HasFile is always false.
Move your code from Page_Load to the Click event handler of the submit button, remove the EnableViewState property, and try again. Not sure if that's the reason, at least, it works in my projects.
-
Hi, I have an asp.net web forms project. No master pages, no ajax, I have a file upload control and when I fire postback the HasFiles property is always empty. I started a new asp.net project. Copy/Pasted the code into it and it worked. HasFiles was retained. Does anyone know why? The code:
protected void Page_Init(object sender, EventArgs e)
{
if(IsPostBack) return;
}protected void Page_Load(object sender, EventArgs e)
{
if(flImage.HasFile){
Application["FileBytes"] = flImage.FileBytes;
Application["FileContent"] = flImage.FileContent;
Application["FileName"] = flImage.FileName;
Application["PostedFile"] = flImage.PostedFile;
}HasFile is always false.
hello pls try this circumstances 1 >> check that if you have updatepanel then you have applied trigger on that one 2 >> check that your page load have !isnotpostback and if yes then in that file upload is not getting null this should be issues may be regards...:)