Load files/folders in client machine - javascript

I want to load all files/folder under path in client machine using jquery. Can we do that? It looks like file browser of window but I want to custom style for it.

Cant be done. Browsers cant access client machine file system.

Related

Modify a local file with Javascript

I must make a local app with an interface. This app should load text files, modify them, and save them.
I made the interface with html/css/js, and the core of the app was made with js only.
Currently, I load the file with an input, but to save it, the browser makes me download it. I know this is a security measure.
This app is not going to be put online.
My question is : what can I do to replace directly the loaded file by the new one ?
Can I use my app (html/css/js) without a browser ?
Is there a browser that allows me to edit my local files directly ?
Is there any solution I can't think of ? Using another language to communicate with the js maybe ?
Thanks.
If you don't need your app to be online, with Electron you can make an executable using your existing code (you will have change how you're going to save the file using Electron APIs).
Being a program running on your system, you'll be able to save directly on the file system.
JS in the browser is not able to edit local files, because of security.
If you want to, you can use Node.js, a Desktop/Server Framework, which uses JS.

Save Javascript or Replace Javascript File in Chrome Developer Tools

Is there a way to replace a .js file in the website sources with a file on my workstation, or make a modification to a .js file and refresh the website to see the changes?
I am developing client-side JavaScript code against a SharePoint website on a server. I cannot create a local version of the website, so I need to modify the script, save the file to the server, refresh, etc. I do not have direct access to the server, and saving a file in a SP doc library or web part takes a lot of time between edits.
I can make small modifications using the dev tools while breaking on certain lines and applying snippets, but I am hoping for a better way.
Thanks!
If you have access the server that's hosting the file you should be able to replace or modify the JS file. Alternately you can use local hosting tools to test your file and then upload it to the server once you've confirmed it's working.
If you explain what you level of access to your host is we can offer better suggestions.

Loading a local image with JavaScript/jQuery where I know the location, but not the file name

The new version of Linux Mint allows HTML 5 login window themes -- I'm trying to write one that will grab each user's wallpaper. These wallpapers are located in the folder /home/#USER#/.cache/wallpaper/, however the file name is not consistent and I need a programmatic way of determining it. Once I know the filename, the login screen will display the image correctly using the file:///.. format.
I don't have any tools other than client-side HTML/CSS/JavaScript[/jQuery/etc] available to me. Is there any way I can grab the file names in that directory, so that I can grab the wallpaper image?
EDIT: Figured it out! The browsers won't allow access to the file:/// resources at all, the mdm-theme-emulator will.
It looks like these files are located on the client machine, in which case you would not be able to access them using jQuery. Javascript does not have access to the local file system.
If you are sending the request through a server, you'd be able to use the server-side code (ASP.NET, PHP, etc.) to loop through the filenames

Using javascript to move a file on a server

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?
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.
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!

How to open an .exe application which is hosted on different server using html?

How to open an .exe application which is hosted on different server using html ?
var w = new ActiveXObject("WScript.Shell");
w.Exec("C:\Program Files\Adobe\Photoshp.exe");
I tried the above code but it's working with local .exe bt nothing is working with external .exe
Assuming this is an intranet stuff, try this:
w.Exec("\\\\Your_server_name\\C:\\Program Files\\Adobe\\Photoshop.exe");
or:
w.Run("\\\\Your_server_name\\C:\\Program Files\\Adobe\\Photoshop.exe");
Your_server_name can also be an IP address. Notice also doubled backslashes, and the fact, that the path must be absolute, you can't use any drive letters mapped in local workstation. Notice also, that usually server name is not the root of the server (like C:), rather it's pointing to a folder in the server.
Both examples work great for me, no matter, if the HTA is saved in the server or workstation. Only I could imagine why they wouldn't work (additional to a wrong path), is a case, when you have not rights to the referred folder. Or... you're trying to run exe from an external WEB server, which afaik is not possible.
I dont think you can do that using JS on client side directly as this will be a security issue. The best way to do this will be first download the exe file, via http and then run it. Once you try to do this user will also be prompted for it.

Categories

Resources