I need full path to file when file is opened. For example user open file.txt but it will be opened with notepad or other. But how to register "hook" from NPAPI plugin to get path to file and prevent opening in other program?
An NPAPI plugin doesn't sound like it's at all the right technology for what you want to do. Plugins are for running native in the context of a specific web page, whereas it sounds like you just want a local application that's registered with the OS as the handler of certain file types.
Related
In a web application I am working on I would like to be able to download files, modify them localy and reupload them to the server.
To make it as easy as possible for the users, I would like them to choose the download location and use a single button to upload the changes afterwards.
My current apporach is the following:
Use window.showSaveFilePicker to choose location and get a FileSystemFileHandle
Download the content and write it to the FileSystemFileHandle
Show a button which allows to upload the changes using FileSystemFileHandle#getFile to get the modified content.
This approach works pretty well but the user has to manually search and open the file after the download and I would like to support them in this step and make it as simple as possible.
Ideally the file should automatically be opened with the default application after the download but I couldn't find a way to do that.
One idea was to open the file in a new tab using the file://-URL, allowing the browser to decide what to do but the FileSystemFileHandle does not seem to expose the absoulte path.
Is there any way to open the downloaded file with the default application? If not, what other possibilities are there to make the mentioned use case as simple as possible?
Thanks in advance
EDIT:
I found that you can open certain applications using special urls like ms-excel:ofe|u|file://path/to/file.xls.
This would be enough for most use cases but for this to work I would need to get the file url from a FileSystemFileHandle.
For security reasons, there is no way for a Web app to open local apps. In the future, though, once file change events are implemented, you can await changes to the file, and then re-open it. This should solve your use case.
I would like to create a link on a web page, which points to a local file. Click it to start a local application to open it. Is it possible? If not, can a plugin of browser or any other approach achieve it?
URL Scheme can help you.
We are able to open a local application by a url like 'openmyapp://****',but you need to create a registry for your application.
ON the Windows System,the content of the registry is like this
[HKEY_CLASSES_ROOT/Alitalk]
"URL Protocol"="openmyapp"
[HKEY_CLASSES_ROOT/Alitalk/Shell]
[HKEY_CLASSES_ROOT/Alitalk/Shell/Open]
[HKEY_CLASSES_ROOT/Alitalk/Shell/Open/Command]
#="/"C://Program Files//Alisoft//WangWang//WangWang.EXE/" %1"
For example I have a html file :
test
On chrome - when clicked the file downloaded to default directory
On IE - when clicked asks to open or download
how somehow when clicked, automatically open it with default program in windows
I dont have any references but i think youre not in controll of that behaviour. You can probably as well configure chrome the way it asks you before downloading and vice a verse configure IE to not ask but download the files in a certain directory.
Maybe there is a possiblity to have a java script code running on page load that initiates a download directly without any notification to the user but that wont run in any cases as well (since youre not in controll if someone switches off java script).
Please I am new to building Chrome Extensions. After the user installs the extension, I want them to configure it by specifying a directory where the app can save files. I want to do this by opening a save file dialog so they can browse to the folder of their choice. How do I do this?
The answer is that there is no means in the Chrome Extension API to write files outside of the sandboxed file system provided by Chrome. This could theoretically be done by writing an interface in C and then call that, but so far I have not yet seen a successful implementation.
In my web app I need to give the user the option to save a js variable as a file (when the user clicks download, the app offers him to save a file, preffereably as .js file).
Similarly as google docs offers you to save a file.
Is it possible for javascript to pass it's variable this way?
Check out Downloadify which allows exactly this.
Downloadify is a tiny JavaScript + Flash library that enables the generation and saving of files on the fly, in the browser, without server interaction.
it requires Flash installed in the user's browser to work, though.
I know of no other way of doing this without server interaction.
You might also want to check out OpenSave:
http://www.gieson.com/Library/projects/utilities/opensave/
... which looks much like Downloadify, but seems to have a few extra features (and not as complicated?).