Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

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

Code:

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

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

Remember, it works fine on the server.

Thanks!

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.