locked
Upload Control Not Working RRS feed

  • Question

  • User-639631676 posted

    I have a website with the asp.net upload control and it works fine while running it on my computer, but when I upload it to the server it does not work, all that happens is the cursor continues to spin when accessed from chrome and edge on my same computer

    I tried it from my mobile and it worked

    This is strange, I contacted the web hosting site and it worked from there local computer 

    Any ideas, if not is there a simple 3rd party one I could use for single and multiple file uploads ?

    Thursday, October 15, 2020 6:00 PM

Answers

  • User-639631676 posted

    Kathy, thanks for your replies

    After retesting my two hosted websites again with the upload control, have actually found out that they do work, but where it took seconds to upload a file for some reason on both separate sites its taking around 30 seconds, so it is actually working but very slowly use to be much quicker

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 16, 2020 1:40 PM

All replies

  • User409696431 posted

    What code are you using to save the file?

    Show us both the upload control markup in the .aspx page, and the code behind in the aspx.cs page that handles that control.

    Thursday, October 15, 2020 6:24 PM
  • User-639631676 posted

    Kathy the code is correct I can assure you as it works when running on my computer and from a mobile phone and the hosting companies local computer, just wondered if anybody knew this as a known issue

    This is the code behind taken back to its bare minimum and still not working

            protected void btnUpload_Click(object sender, EventArgs e)
            {
                    string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);

                    FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Pdf/") + fileName)            }
            }

    Thursday, October 15, 2020 6:51 PM
  • User-639631676 posted

    I have deleted the code in the onclick event and put in a message instead, but this code appears to not get run, the click event is not working ?

    Thursday, October 15, 2020 7:13 PM
  • User409696431 posted

    How did you put in a message?

    The FileUpload control works just fine (used it in many sites, for many years), so there is something else going on.

    You can simplify your code, by the way, by getting the filename as

    string fileName = FileUpload1.FileName;

    I'm not sure what the Path.GetFileName is doing there.  (What does that value show when you run it?)

    Thursday, October 15, 2020 7:33 PM
  • User409696431 posted

    If the button click event is not working, that has nothing to do with the file upload, and it seems very improbable if you have correctly wired it up to the button.  (And it certainly would not work differently locally and remotely and mobile.)

    How did you display the message?

    Thursday, October 15, 2020 11:32 PM
  • User-639631676 posted

    Kathy, thanks for your replies

    After retesting my two hosted websites again with the upload control, have actually found out that they do work, but where it took seconds to upload a file for some reason on both separate sites its taking around 30 seconds, so it is actually working but very slowly use to be much quicker

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 16, 2020 1:40 PM