The site has the ability to upload a file using a standard browser form. "Select File" button.

<form class="file-form" enctype="multipart/form-data" method="post"> <input type="file" class="file-for-import" required="required" /> </form> 

Action handling is done using the Marionette framework.

 var MainImportView = Mn.LayoutView.extend({ template: $(html)[0].outerHTML, ui: { file: '.file-for-import', generate: '.gen-tab', import: '.to-import' }, events: { 'click @ui.file': 'loadFile', // read content from file 'click @ui.generate': 'readFields', 'click @ui.import': 'import' }, loadFile: function(e) { var file = this.ui.file[0].value; }, ... }); 

And this file is defined as C: \ fakepath \ test.txt , although the selected test.txt file is in a different directory and generally on disk D. Why is the correct path not loaded?

  • one
    This is not a specific Marionette thing, but restrictions at the browser level for security purposes. - Duck Learns to Take Cover
  • @ Duck So, to download a file, you do not need to know the full path to it? - Mae

1 answer 1

Like @ Duck said, the standard C: \ fakepath path is set by many browsers so that third-party javascript does not have access to your file architecture. This will load the file normally. The issue is resolved.