How to verify file exists with asp:FileUpload

B

Ben Rush

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.
 
B

bryanp10

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.
 
B

bryanp10

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
 
K

kwendex

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top