Download multiple files from remote server with a single user confirmation - javascript

I have a web page containing a list of pictures urls (can be more then 1000 items) and I want to enable a button for the user to click and download all of the files to the local hard drive.
The download process should ask the user for a directory to save the files in and then go ahead and download all files to that directory (if possible, creating sub directories inside). This should be done with a single user confirmation for the whole download process and avoid display the browser save dialog for each file.
Is there a way doing that? I am aware I can't use the standard HTTP protocol for the downloads and have to write some kind of control to do the job. The page is written in asp.net.
Downloading to the server, packing and sending to the user is not possible. The download has to be originated from the client machine.

You should update your question to include the requirements from your comment, because they make a huge difference. If the server cannot retrieve the files, because he doesn't have the right permissions, your only option is to run the code on the client side. There are several options how to do this, mostly depending on the clients and your coding skill:
Flash (Not sure about the security aspect of writing to the local file system, though)
Java Webstart (Disadvantage: Clients need to have the Java runtime installed)
Browser plugin/extension (Disadvantage: You can only support a subset of browsers and the page will not be immediately usable, as the plugin or extension needs to be installed first)
In all cases, you will have to write a tool, that retrieves the URL list from your server and starts downloading it.

Related

How to save uploaded image in any particular folder

I am new to web dev and currently building a very basic page using Html/CSS and JS where users can upload the image and I can download it in my local system. But by default images are getting downloaded in the 'download' section of my desktop and I want to save them to any specific folder. How can I add this functionality?
You can't.
You do not have access to other peoples file managers as that would be a major security risk.
Uhh... You can't manipulate the download folder from frontend. It may be a security risk.
This cannot be done by Javascript (otherwise we could all produce websites which saved files all over a user's local PC).
As the end user in this case you can go into your browser and tell it which folder to save downloads in by default. (And remember to change it back if you want any other downloads to go elsewhere).
Here for example is what I find on Edge on Windows10 when going into Settings>Downloads:

Automatically list directory contents in client side Java Script?

I need to create an HTML page that will generate a list of hyperlinks to the contents of the client side directory in which it resides.
This would allow HTTP browsing of a local NAS, where no web server involved and contents can change dynamically.
This might be extremely useful to anyone serving content on a LAN. We need this feature in an educational setting, where directory contents will change frequently. Making manual links would be prohibitive, and file browser access is also needed.
Our Digital Media program will be much obliged to anyone who can help us with a solution.
Without any kind of server/back-end code, an in-browser NAS file explorer is not possible. Client-side JavaScript only interacts with the client. It's possible for client-side JavaScript to contact a server, however, and retrieve information about that server's directory structure, but, of course, that would require a server where you say you can't have one.

Changing download folder for a specific web application

I think the answer is going to be "not possible" but it doesn't hurt to ask.
I've created a web application for a specific user that in part creates Word Doc documents on the server that they then download to their local machines.
My end user is not an experienced computer user and occasionally "loses" the files they've downloaded. (They're in the default download directory mixed in with other things they've downloaded!). It would be preferred if files downloaded from my web application went to a specific folder.
Is there a way to do this either in the web apps code or as a configuration of their browser?
The web app is built using MS Web API 2/C# for the server and Javascript/JQuery/Knockout on the client side.

Javascript local file saving or onSave event to get saved filename

I'm developing a web app that needs some sort of filesystem access. Ideally I'd want to be able to "Open..." a file into the app and then "Save" the file back to local filesystem at the location that the user opened it from.
Currently, we use a java applet to achieve this functionality, but since java is going out of style, we're needing to do this with javascript and html5.
Obviously, this can't be done because of security reasons built into browsers, so I'm trying to somewhat emulate it.
I'm using the html5 file api to successfully import/open the files, so that's half the battle. The hard part is getting the saving feature. I'm getting close using an iframe and content-disposition, but problems arise when browsers are set to automatically download the files to a downloads folder... users may get confused and be unable to locate the file they just downloaded.
So, my question is this: is there some sort of onSave event or some kind of way for the browser's "Save As..." window to return at least the filename that the user saved the file under?
Also, I've looked into the filesystem/fileWriter html5 apis, but from my understanding they're limited to only a sandboxed area of the local filesystem and only available in chrome dev releases.
Any help would be appreciated!
No, there is no way to do that with pure JavaScript. You can manage to trigger a download with data URIs or an iframe with some headers but you can't circumvent the browsers' download managers.
You can either use a Flash or Java applet to handle the saving for you, or ask the user to right click on the link and do save as, then he might be able to choose the destination.
One popular option using Flash is Downloadify.

How to read and run files on hard drive from a webpage?

Here's the gist of what I'm trying to do:
A user will have to match his fingerprint (captured image) with an image stored in the server. I've implemented the image matching program in OpenCV and it's a .exe on disk. The output of this is flag.txt.
Basically if the value of flag.txt is non-zero the user may gain access to the next webpage.
The question is - how to I run the .exe and read the contents of the resultant text file (saved on the hard-drive) from a webpage?
EDIT - please note, I am not sure under which tags this falls.
You need to implement kind of web service which will execute you .exe files and do other logic and access this web service from web page. Browser won't allow web page do such actions because of security reasons

Categories