Jay
Jay

Reputation: 1309

Getting the property of a file (last modified date) from user's local system

I can store the user selected file in localstore using the below code and able to access back whenever user want to reuse it.

In my case I need to get the property (last modified date) of the local file using real path (file:c:\data\test001.txt) before reusing the file from localstore because it might have latest changes. if it has changes I can retrigger the file uploaded to user.

I know we can't read/upload the file using real path (file:c:\data\test001.txt) because of browser limitation.

//save the file in local store
var keyFile = 'ButtonFileFull';
localStorage.removeItem(key);                  
var file = $("#systemPath")[0].files[0];
var reader = new FileReader();
reader.onload = function (e) {
    localStorage.setItem(keyFile, reader.result);                   
}
reader.readAsDataURL(file);

Upvotes: 1

Views: 169

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074258

You can't do that without the user reselecting the file. Although you can get that date from the lastModified property of the File instance you're getting from $("#systemPath")[0].files[0], that means...you have to have the user select the file in #systemPath again. :-(

Upvotes: 1

Related Questions