Upload from local drive to local filesystem in HTML with Filesystem API

HTMLJavascriptProgramming Scripts

<p style="">To upload from local drive to the local file system, we can use &minus;</p><ul class="list"><li>Webkitdirectory attribute on &lt;input type=&rdquo;file&rdquo;&gt; &minus; This allows the user to select a directory by the appropriate dialog box.</li><li>Filesystem API is a sandboxed filesystem, which allows us to store files on client&rsquo;s machine.</li><li>File API allows us to read files. Files are accessible by &lt;input type=&rdquo;file&rdquo;&gt; element</li></ul><p>All of the above is working fine in Google Chrome.</p><p style="">WebKit directory is a much better option among these. Use the following for directory &minus;</p><pre class="result notranslate">webkitRequestFileSystem( &nbsp; &nbsp;window.TEMPORARY, 5 * 1024 * 1024, function(_fs) { &nbsp; &nbsp; &nbsp; fs = _fs; &nbsp; &nbsp;}, Err</pre><p style="">Above, err and fs are &minus;</p><pre class="result notranslate">var fs, err = function(err) { &nbsp; &nbsp;throw err; };</pre>
Updated on 24-Jun-2020 14:09:06