Javascript: how I can read files and folders from usb flash drive - javascript

I want print PDF files from usb flash.
Now I decide do this with Mozilla Firefox and Plugin R-kiosk trought open libruary PDF.js
But still have a problem: how read folders and files to build tree without <_input /> cause it allow user get in system.
Any idea? Thx
May be you can give advice the best way to realise idea without browser... But I don't work with pdf libruaries, output and rendering of pages I have simply understanding, but I can't say this about silent printing of document

I don't believe this is possible. Browsers like Firefox generally won't let you have access to the local file system / disk structure for security reasons. Even if you knew the local path of the PDF, it wouldn't be of much help.

Related

Local filesystem & web browser

Please, does anyone know what are the possibilities for accessing local filesystem from a browser? The use case I'm looking for is whether it is even possible to create a really simple text editor which could save text files locally? If so, what technologies does it take to implement such thing?
I know, historically, that it was certainly not possible to this. But now that we have Ajax and co. it is sometimes possible to open local files. There is even some form of local database (ok, not a file), maybe the extensions for a certain browser are allowed to write a file into a certain (predefined) location and then there is the local web server which could as a kind of proxy. And I even saw [1], though I'm not sure how well is it supported. What else?
In other words, suppose you open Notepad, type same text. Now you click "Save", it asks for the path and saves it [2]. Next time you save the file it remembers the path and saves the new content immediately. Is this possible with browser?
[1] http://dev.w3.org/2009/dap/file-system/pub/FileSystem/
[2] see e.g. http://www.nihilogic.dk/labs/canvas2image/ ("Save PNG")
The are some new html5 javascript methods, called file api and filereader api. I only have experiences with the file api. Tried it some time ago and found it not consistent between FF and Chrome yet.
You can find further information on MDN:
https://developer.mozilla.org/en/DOM/FileReader
https://developer.mozilla.org/en/Using_files_from_web_applications
Back in 2020, you are probably after Electron JS, which offers an independant-OS platform to develop desktop programs with the use of JS, Html and CSS. It uses Chromium and NodeJs. Known apps are the GithubDesktop (Github is one of the founders of ElectronJS), WhatsApp and VSCode.

Making a Chrome extension to download (not view) the link and with custom filename

I'm currently developing a simple javascript extension for Chrome. The problem is simple but probably unfixable, but still here's the issue:
on particular pages, i embed links to some files (i don't have access to server, so i can't change the way they are outputted) - a simple <a>nchor tag.
then, what i'm trying to achieve is:
set a filename of downloaded file (right now it's like 87sfhkjhsf and without extension)
make the browser download (not view) the file in any case (right now, if it's a pdf, it gets viewed.. or if it's an mp3 it gets played with native Chrome player)
i would even accept a .dll solution IF it will really work (i even tried using Flash with FileReference.download method, but it doesn't allow to download files from other domains)
seeking help from you guys :)
In or to programmatically download a file using javascript in chrome you (currently) need either a server to bounce the download off, to be satisfied with garbled filenames (using blobbuilder; this sounds like what you are doing), or a NPAPI plugin (such as a custom .dll or Flash).
If you look at the screenshot extensions, the most popular ones use NPAPI.
I plan on using NPAPI myself, but haven't gotten around to coding for all 3 OSes yet. (I am the developer of Smooth Gestures, and have gotten many requests for a image download gesture)
All this said, there is constant development on filesystem access for javascript and a native API may become available. But I wouldn't hold my breath.

javascript jquery file opener

i was wondering if anyone knew a quick solution to my problem. I want to be able to open a folder on users screen pretty much the same as but just opening up the my computer folder so a user can drag a file onto the browser screen. anyone know how?
You can't. They even gave this bug a name: "security".
The closest you can get without using Flash, proprietary browser stuff or Java is something like this.
You have to use a java applet.
Javascript has no access to the file system for security reason.
Every page would be able to see the files on your local machine and might display: "According to the files on your disk you might be interested in some of our special movies ;)"
Incidentally, there are custom extensions in IE and Firefox that let you load and save files; it's the reason TiddlyWiki can work as it does. It does degrade a Java applet for other browsers.
A new jQuery plugin has been extracted out of TiddlyWiki to give Javascript authors the ability to load and save, and it's portable across all browsers:
twFile - http://jquery.tiddlywiki.org/twFile.html
It's quite possibly not what you're after as it will only work off a file:/// URL.

Get file path through javascript

I am having a file upload control in my page.
I want to get the full path of the uploaded file by javascript.
i have written
document.getElmentById('fileControl").value;
It is showing the full path in IE but in mozilla 3.5 it is showing only the filename not the path.
So how to solve this problem ?
This will be a security issue. Reading the file path of the client machine is not a good idea and won't be allowed by most of the browsers.
Firefox doesn't let you see the path to the file by default - apparently there is a workaround for it but it requires the user to go to about:config and change a setting, which let's face it, ain't going to happen most of the time.
If you absolutely need this (I can't see why though) then you could look at using Flash as a cross-browser alternative, google for Flash and file uploads.
Otherwise, you'll need to work with the limitation here (which in my mind is a very good one!)

Saving a file with Javascript in S60v3 mobile browser

I'm busy experimenting with TiddlyWiki and trying to get it to run on my Nokia E51, which uses S60v3. The browser is based on webkit, which should mean that I'd be able to get it to work, but no luck so far.
Does anyone have any experience with saving files locally on this platform?
I skimmed through the source of TiddlyWiki. For its file operations it is using the jQuery.twFile plugin which in turn uses a custom Java applet on Webkit-based browsers. The S60 browser does not support java applets so I'm afraid you're out of luck.
I may be wrong here but a quick look at the widget training course on forum Nokia makes it seem like file system access from JavaScript isn't available on S60.
http://www.forum.nokia.com/Tools_Docs_and_Code/Documentation/Web_Technologies/
It really look like you're supposed to retrieve persistent data from the network.
I would hope the web browser cache allows you to query remote data several times while only transfering it once.
On my E51 I am able do download files the old-fashion way: A simple link to a file with a fitting mimetype.

Categories