SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a section of code that lets users attach files to list items. The goal is to allow any user to be on the SP site and upload any "legal" file from their machine or shared drives to the site, where they are attached to the list item. I'm able to attach files this way when I RDP to the server and run it there but it doesn't work on any clients. Before I added the second "if" condition I was getting File Not Found exceptions with the exact path listed in the error, where the file is.

Markup (can't get it to show without the pre tag...please ignore it):

<asp:FileUpload runat="server" ID="inputFile" />
<asp:Button runat="server" ID="btnAddDocument" OnClick="btnAddDocument_Click" Text="Upload" />


    protected void btnAddDocument_Click(object sender, EventArgs e)
            if (inputFile.PostedFile.FileName == "" || !File.Exists(inputFile.PostedFile.FileName))
                lblError.Text = "No file selected or file not found";
                lblError.Visible = true;

More code follows but the second condition is never satisfied. PLEASE...What am I doing wrong?

Remember, it works fine on the server.


share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.