-3

I want the file name in description. When user submit the anyfile from frontend, the file name will show in separate div. i am using asp.net mvc framework so, can anyone help me in it.

Malik
  • 3
  • 3
  • You should post the code which receives the request so that an appropriate answer can be constructed. – Derrick Nov 15 '19 at 15:07
  • 2
    Hi and welcome on SO! Please read the [how-to-ask page](https://stackoverflow.com/help/how-to-ask) and read [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/minimal-reproducible-example) to improve your question and help us to understand your problem. – nilsK Nov 15 '19 at 15:07
  • Possible duplicate of [Javascript - How to extract filename from a file input control](https://stackoverflow.com/questions/857618/javascript-how-to-extract-filename-from-a-file-input-control) – Derrick Nov 15 '19 at 16:06

1 Answers1

1

To determine the name of the uploaded file in your controller.

In your ActionResult function:

    if (Request.Files.Count > 0)
    {
        var data = Request.Files[0].InputStream;
        var filename = Request.Files[0].FileName;
    }

You can then pass the filename back to the view.

Please see this question for how to determine the filename using javascript:

Javascript - How to extract filename from a file input control

[The question is not clear as to whether you are trying to determine the filename from the post on the server side, or if you are trying to determine the filename within the page]

Derrick
  • 2,502
  • 2
  • 24
  • 34
  • on the same page i want to show the details of document. the page don't redrrict to other page – Malik Nov 15 '19 at 15:32