W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2011

[whatwg] creating a new file via the File API

From: David Karger <karger@mit.edu>
Date: Mon, 15 Aug 2011 13:40:40 +0300
Message-ID: <4E48F7A8.3060608@mit.edu>
Apologies if I'm revisiting old territory.  I've been doing work on pure 
html/javascript applications that work entirely clientside 
(http://projects.csail.mit.edu/exhibit/Dido).  For persistence, they 
read and write local files.  There's already an <input type="file"> 
interface for letting the user specify a file to be read.  And I can use 
the same interface, inappropriately, to let the user overwrite a 
preexisting file.  But things get much messier if I want to let the user 
specify a _new_ file to be written, because the file-open dialog doesn't 
offer users a way to specify a new filename.  What I'd like to be able 
to do is specify a tag, or a invoke some javascript method, that will 
produce the "save file" dialog typical of most systems, with a graphical 
directory browser but including the option to specify a new filename.  
This problem isn't unique to me; a discussion on stackoverflow appears 
at 
http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file 
where the proposed solution is to use flash---and that would be an 
unfortunate loss of html5 purity.  They also suggest the hack of using a 
data: url but that has size limitations.

Perhaps <input type="file"> could be given an attribute specifying 
whether a new filename is permitted?

-David Karger
Received on Monday, 15 August 2011 03:40:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:35 UTC