0

I'm in need help in coding a web page in HTML5 where I can browse a file and enter a name in a text box and specify a location so that the portal can rename and save the file at location specified.

The problem is I'm not supposed to use any server side languages like PHP or Perl.

Is there a way that I can achieve this using JavaScript or jQuery or any Client side executable languages.

Any insight is much appreciated.

royhowie
  • 11,075
  • 14
  • 50
  • 67
sathyam1992
  • 145
  • 1
  • 3
  • 13

2 Answers2

4

No. That would be an enormous security loophole. You cannot programmatically change the client's file system.

royhowie
  • 11,075
  • 14
  • 50
  • 67
  • This is not a server controlled management. I want to organize my files using a webpage without installing any server services like Apache. So I don't think there will be any issue of security loophole. – sathyam1992 Apr 30 '15 at 21:19
  • 1
    @sathyam1992 that's not what I was saying; browsers simply don't allow unlimited access to the file system because someone could write some malicious code that, when you visit their webpage, deletes all your files or something terrible. – royhowie Apr 30 '15 at 21:21
  • This has recently changed. Browsers can modify local files if they support the [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API). – Anderson Green Feb 15 '22 at 23:28
0

You can do it with the fs (filesystem) api in node.js.

var fs = require("fs");

fs.rename("/tmp/hello", "/tmp/world", function (err) {
    if (err) {
        throw err;
    } else {
        console.log("rename complete");
    }
});
royhowie
  • 11,075
  • 14
  • 50
  • 67
lem2802
  • 1,152
  • 7
  • 18