Debu
Debu

Reputation: 49

why this code is not create a file in html5

i want to create a 'abc.txt' file in the folder where the .html file exist. in html5. i tri with this code:

<html>
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
function onInitFs(fs) {
fs.root.getFile('abc.txt', {create: true, exclusive: true}, function(fileEntry) {
}, errorHandler);
}
window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
</script>
<input type="button" name="" id="" value="click" onclick="onInitFs(fs);"/>
</body>
</html>

But faild. Please tell me the correct method. (i tri with google chrome and letest firefox.)

Upvotes: 0

Views: 41

Answers (1)

Quentin
Quentin

Reputation: 943567

From the documentation:

The LocalFileSystem interface of the File System API gives you access to a sandboxed file system.

It doesn't give you access to the main filesystem for the computer. It is a virtual one created by the browser. You can only access files in it that you put there from your own code.

Upvotes: 1

Related Questions