locked
Problem uploading with MS Edge RRS feed

  • Question

  • User-1209166642 posted

    First please see this post: https://forums.asp.net/t/2166962.aspx

    The code in that post works perfect in Firefox and Chrome.  However it does not in Edge.

    For example, if the image is located at C:\Users\jimwin7a\Pictures\ann.jpg

    Firefox works and just ann.jpg is stored for file name, but Edge stores this for file name C:\Users\jimwin7a\Pictures\ann.jpg

    Actually something like ann37.jpg (see the code that works in other post).  And image isn't uploaded to server, it put in same folder you get the file from.

    Why in the World wouldn't Edge handle proper file uploads?

    Again code here https://forums.asp.net/t/2166962.aspx works perfect in the other two mentioned browsers.

    So any help would be nice.

    Tuesday, June 2, 2020 3:38 AM

Answers

  • User-1209166642 posted

    I was able to fix by adding this:

    added           string Result = Path.GetFileName(filename);  //MS example I found
    changed to      Array getparts = StrHelper.SplitString(Result);
    
    //  Now works in Edge and FF and Chrome.

    I hope it helps someone.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 3, 2020 2:18 AM

All replies

  • User475983607 posted

    Why in the World wouldn't Edge handle proper file uploads?

    The application should name the file not the client.

    https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-3.1

    Use a safe file name determined by the app. Don't use a file name provided by the user or the untrusted file name of the uploaded file.† HTML encode the untrusted file name when displaying it. For example, logging the file name or displaying in UI (Razor automatically HTML encodes output).

    Tuesday, June 2, 2020 10:25 AM
  • User-1209166642 posted

    I was able to fix by adding this:

    added           string Result = Path.GetFileName(filename);  //MS example I found
    changed to      Array getparts = StrHelper.SplitString(Result);
    
    //  Now works in Edge and FF and Chrome.

    I hope it helps someone.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 3, 2020 2:18 AM