0

So I have this html page. Inside of it is a bit of javascript code that talks to a flash application.

During the flash application's lifecycle, it'll save a file to a place on the server using the javascript on the html page.

How can I use javascript to take the file I just saved and move it to a different location?

2 Answers2

3

You cannot. Javascript works on a client and don't have an access to the server's filesystem.

You can only trigger a script on the server that does that.

zerkms
  • 249,484
  • 69
  • 436
  • 539
  • How would I go about doing this? I have node.js installed. Can I utilize that? I know python has `os.command("string")`, where they can access the server's command line, but I'm not running anything python –  May 30 '13 at 22:04
  • You can use a jQuery/ajax script to do it. Are you familiar with ajax? It's not as difficult as it sounds. However, the ajax will still run a PHP file on the server that does the actual work. Why can't you just do all this in PHP? – cssyphus May 30 '13 at 22:16
0

As you said you have node js installed and running on the server,it is possible for you to move a file using the nodejs filesystem api: http://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback

For this to work you would need to monitor and detect when new files are saved in a certain folder, which should be possible using: http://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener

Happy coding!