Search code examples
htmlfileapi

HTML5 - how to detect a file is accessible


In my app I upload a file to the server using HTML5 File API, however I am encountering a situation where a file is not accessible because it is being used by another process. This actually creates two different error conditions in firefox and in chrome. Is there a way to detect if a file is inaccessible using html5?


Solution

  • Have you looked the sample in this link which shows how you can read a file and in case of error you can write proper error handler:

    http://www.azoft.com/spotlight/2011/02/02/filesystem-apifile-api.html

    About your second questions "if there's an API call to just check if it is readable without actually having to read it locally", I verified that there is no such API to just get the file handle state and verify it. I think it could be because (but i may be wrong):

    • the web application runs on any box with limited privilege and getting file handle could require SYSTEM level access
    • The file handle access could be different for different OS (Linux or Windows)