473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="multip art/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="multip art/form-data" runat="server" method="post"
id="frmFileUplo ad">
<asp:FileUplo ad ID="fuFilename " runat="server" Width="400" />
</form>

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

May 8 '06 #1
5 3496
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(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
...
// code doesnt get called when upload button is pressed
}
}
#endregion

#region UploadFile_Clic k
public void UploadFile_Clic k(object sender, EventArgs e)
{
if (fuFilename.Has File)
{
// code doesnt get called as its saying HasFile is false
}
else
{
lblNoFile.Visib le = 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.len gth is greater than
0. This is what I normally do.

May 8 '06 #4
I tried checking the filecontent.len gth 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
2930
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 & onItemUpdating but no luck.. FindControl() didn't work and can't find my fileUpload control.. any help plzzzzzzzzzz?? I just upgraded to .net 2 and...
1
7034
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 follows: <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title> drag </title> </head> <body> <form id="f1"...
12
15650
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 Html File Input control to using the new FileUpload control. Previously, I had set the maxRequestLength attribute in the machine.config file to...
2
8023
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"> <title>Untitled Page</title> </head> <body>
0
1318
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, ByVal e As DetailsViewInsertEventArgs) Dim FileUpload As FileUpload = DetailsView1.FindControl("Bild")
4
5666
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 (FileUpload)FormView1.FindControl(FileUpload1).FileName doesn't work. The purpose is to insert a graphic in the InsertItemTemplate section of the form. I'm using the expample that's in the online...
3
5164
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 e.g. if the BackColor of a FileUpload control is set to blue, then only the TextBox color changes to blue but the BackColor of the Button doesn't...
5
12079
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
229
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 those browsers? I have created a class to handle these operations, but i don't see this a factor. Thanks you -- Share The Knowledge. I need all...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.