Hi,
Below is the File Upload control, which I am using to upload the file in a ListBox.
TechData :
@Html.ListBoxFor(m => m.UISelectData, Model.DataList, new { @class = "form-control", @id = "lbTDT" }).DisableIf(() => Model.IsActiveSnapShort == true)
<div class="btn btn-default fileinput-button">Browse
<input id="fileupload" type="file" name="files[]" multiple onchange="getfilename(this, 'lbTDT')">
</div>
I am trying to get the full/complete path of the location from where I am browsing the file to upload.
<script>
function getfilename(id, lstbxId) {
debugger;
var fileUploadpath = $(id).val(); //getting the path of the browse location
var webConfigPath = $('[id*=hfFeedfileUploadPath]').val();
if fileUploadpath != webConfigPath ) {
alert('Path does not match');
}
else
{
//upload file functionality -- already done
}
</script>
In "var webConfigPath" I am getting proper path which is set in web config file.
But in "var fileUploadpath = $(id).val();" I getting path like: C:\fakepath\fileName.xlsx
I know the reason of this but I want to fetch the proper location/path which I am browsing to upload the file.
Ex- C:\Users\ABC\Documents\fileName.xlsx
Here, selected File names are correct but the path is not the one I am browsing.
Please help how to get the exact file browse path inside JavaScript/JQuery ?
I checked this link as well: FakePath problem while geting Path in ASP.Net FileUpload control
but still I am unable to fetch the correct path inside JavaScript.
Please help me to achieve it. Thanks in advance