473,387 Members | 1,485 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,387 software developers and data experts.

How to verify file exists with asp:FileUpload

How do I do a client-side check to see that a file exists before
attempting to upload it? I am trying to avoid the "Access denied"
error I get on form submission if an invalid name is entered in the
textbox.

This page does it beautifully:
http://msconline.maconstate.edu/tuto...pnet09-11.aspx

But how???

Seems like an obvious feature to discuss, but NOTHING I've seen online
explains how to do.

Mar 30 '07 #1
4 6578
I'm afraid I don't know what you mean. I created a very simple aspx page
using an upload control from ASP.net and it seemed to work exactly as the
one hosted on the page to which you're linking.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" /></div>
</form>
</body>
</html>

Perhaps I am missing something fundamental in your question? If I type some
garbage into the upload text box and click to upload, the behavior is the
same as this other one.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
<br******@hotmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
How do I do a client-side check to see that a file exists before
attempting to upload it? I am trying to avoid the "Access denied"
error I get on form submission if an invalid name is entered in the
textbox.

This page does it beautifully:
http://msconline.maconstate.edu/tuto...pnet09-11.aspx

But how???

Seems like an obvious feature to discuss, but NOTHING I've seen online
explains how to do.

Mar 30 '07 #2
Interesting... so with this little code you just posted, when you
insert a file name like:

c:\missingfile.txt (valid file name, but doesn't actually exist)

You see a little message popup that says "The file missingfile.txt
does not exist" and it doesn't post back? Because I'm certainly not
seeing that. Did you check the link I posted?

What I see is that the page posts back and the file size posted is 0
bytes. If I use an invalid file name (no path, bad chars) it simply
doesn't post back, but there is no feedback.

Obviously there is something wrong in my app because I'm getting an
"access denied" javascript error that I am not sure how to catch or
account for when submit() is called.
Mar 30 '07 #3
Sheeeeit. I just realized what is going on. The behavior is browser-
specific... duh! IE does not provide any feedback and will postback
even if the file doesn't exist. If it's an invalid filename it will
simply not post back. Opera, on the other hand, pops up a message that
says the file doesn't exist in both cases and does not post back.

To this day, it amazes me that Microsoft was able to capture so much
of the browser market. :P

Mar 30 '07 #4
Sheeeeit. I just realized what is going on. The behavior is browser-
specific... duh! IE does not provide any feedback and will postback
even if the file doesn't exist. If it's an invalid filename it will
simply not post back. Opera, on the other hand, pops up a message that
says the file doesn't exist in both cases and does not post back.
Yup. That sort of thing is very browser based.
To this day, it amazes me that Microsoft was able to capture so much
of the browser market. :P
It came preinstalled on the most widely-used operating system on the
planet. Makes sense to me :)

Mar 30 '07 #5

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

Similar topics

4
by: Marko Vuksanovic | last post by:
I am trying to cause the uplaod button, id="Upload",when clicked, to exectue the onClick event for Button1, id="Button1". <asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>...
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...
0
by: =?Utf-8?B?TGVvbkc=?= | last post by:
I'm trying to upload a file using an asp:FileUpload control and an asp:LinkButton. This works fine, while there is an actual filepath in the fileupload upload control. Even an empty field works....
2
by: Bart | last post by:
Hi, i use the FileUpload control but if the uploaded file already exists, i want let the choice between overwriting or not the existing file. Therefore i use a radiobuttonlist with 'yes' and...
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
4
by: Mukesh | last post by:
i have coded like this <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server"> <asp:FileUpload ID="fupLogo" runat="server"...
5
by: =?Utf-8?B?VEQgaXMgUFNQ?= | last post by:
I have a FileUpload control within a FormView (although I tried it outside the FormView and got the same result) in the InsertTemplate. When the <Insertbutton is clicked and the Insert Command is...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.