473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

FileUpload problems

Hey all,
I hope someone can help me on this one as it's driving me nuts.

Basically i have the asp:fileupload control embedded on my page but,
hasfile 'always' returns false. I have tried using the
enctype="multipart/form-data" on my form but that doesn't make any
difference.

I have this working on an asp.net 1.1 (using <input type=file>) and
it's fine but this sites asp.net 2.0.

My code is as follows:
<form enctype="multipart/form-data" runat="server" method="post"
id="frmFileUpload">
<asp:FileUpload ID="fuFilename" runat="server" Width="400" />
</form>

Is there anything I'm missing? Any ideas much appreciated!
Andrew

May 8 '06 #1
5 3481
I think the interesting thing is more your code behind. There seems to
be nothing wrong with your HTML markup except that it's not necessary
to specify the enctype.

May 8 '06 #2
Cheers for getting back to me Jacob, appreciated. There isn't really a
lot going on in code-behind but what I have is:

#region Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
...
// code doesnt get called when upload button is pressed
}
}
#endregion

#region UploadFile_Click
public void UploadFile_Click(object sender, EventArgs e)
{
if (fuFilename.HasFile)
{
// code doesnt get called as its saying HasFile is false
}
else
{
lblNoFile.Visible = true;
}
}
#endregion

Any ideas?
Cheers,
Andrew

May 8 '06 #3
There's a thread here -
http://www.developersdex.com/asp/mes...2910&r=4884890

Sounds like the problem is that the file stream is not being sent or
that it is being erased before being used. You could try to check
whether other event handlers overwrite the value before the click
handler gets fired.

Another option is to check that the filecontent.length is greater than
0. This is what I normally do.

May 8 '06 #4
I tried checking the filecontent.length but that was zero. I will try
checking out any other events that could be firing and removing the
file...

May 10 '06 #5

Solved.

There was another form wrapped up around the <body/> contents that
seemed to affect the file upload.

Thank you for your help Jacob and I hope this helps anyone else with
this problem! I knew it had to be something stupid :-)

May 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
1
by: Marko Vuksanovic | last post by:
I am trying to implement an upload progress indicator using atlas, using the following workaround: http://forums.asp.net/thread/1321664.aspx This is the code in FileUpload.apsx file is as...
12
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
2
by: Paolo | last post by:
Hi to all, I have an error that drove me crazy. Try the following page that should only allow to upload a file: <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">...
0
by: Christian Schlemmer | last post by:
If my code will run into the filesize-limit condition, the INSERT-statement will be executed. is there a way to avoid that? Protected Sub DetailsView1_RowInserting(ByVal sender As Object,...
4
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
5
by: =?Utf-8?B?QmVydA==?= | last post by:
Hi How can you set the filename property in the asp:fileupload control? How can you persist the value of the chosen filename between postbacks? thanks B
6
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
I have created a simple fileupload page for image files. It woulds without problem with ie7. However, FireFox and Safari will not upload an image file. Is there some issue with the control and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.