Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:24:23+00:00 2026-05-24T13:24:23+00:00

I am trying to use the html file input to get the path and

  • 0

I am trying to use the html file input to get the path and name of a file. I do not want to upload the file however, and seeing as the files can be quite large, I do not want to pass the file data back to the server either just to get the filename.

Is there a way to bind the file input value to a property in my model, or at least pass just the filename back to the server?

Here is my code:

@using (Html.BeginForm("Upload", "Management", FormMethod.Post , new {enctype="multipart/form-data"})) {
    <div>
        Upload New Pricing Workbook: <input type="file" name="browse" id="browse" />
    </div>

    <div>Was Won: @Html.EditorFor(file => file.WasWon)</div>

    <div>
        <input type="submit" name="upload" id="upload" value="Upload" />
    </div>
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:24:23+00:00Added an answer on May 24, 2026 at 1:24 pm

    Is there a way to bind the file input value to a property in my model, or at least pass just the filename back to the server?

    You will need javascript for this. You could include a hidden field to your form, and then subscribe for the submit handler of the form and inside this handler set the value of the hidden field from the value of the file input field and clear the value of the file field. Also if you are not interested in uploading the file you don’t need the enctype attribute on the form

    $('form').submit(function() {
        $('#someHiddenField').val($('#browse').val());
        $('#browse').val(''); 
    });
    

    All this being said, for security reasons you cannot get the entire path to the file on the client computer using javascript. You will get only the filename using $('#browse').val() and that’s the best you could hope.

    If you want to get paths you could include a standard input field and let the user type it in. This way you will get on the server only what you need (a path to some file).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the WebClient class to download a html file from another
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
Here is my html form <div id=create> <form action=index.php method=get id=createform> <input type=text name=urlbox
I am trying to get the javascript code from an html file using C#
I am trying to use an HTML form and javascript (i mention this, because
alt text http://www.freeimagehosting.net/image.php?a55fa98f01.jpg Hi I am trying to use a HTML select box with
I'm trying to use Ajax to fetch an HTML page and then pull out
I am trying to use XPath to extract some HTML tags and data and
I am trying to use load() to place some html into a div on
I am trying to use html5lib to parse an html page in to something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.