Instruct browser to make user select location for downloaded file? - html

Some browsers has the option to automatically save downloaded files to a folder, without prompting the user where to save the file. This has posed a problem for us where the user automatically saves the file in "Downloads" instead of selecting a proper location.
Is there any HTML-attribute, HTTP-header or JavaScript solution to instruct browsers to prompt for save location for downloaded files even though they are configured otherwise?
Note: I am well aware that this is probably not possible, but wanted to see if someone hopefully can prove me wrong.
Related issues:
How to make browser download link target instead of navigate: Force to open "Save As..." popup open at text link click for pdf in HTML

No. It's a browser preference. If the user prefers not to be bothered by their browser for download locations, then that's their prerogative. They'll deal with the file location after it has been downloaded. A server cannot influence that behaviour.

Related

Is there any way to open a local file from a html code in google chrome?

so, i've ben hunting for the answer, and seems like i can't get this to work, i wanted to make so that, i have a browser page already made in html, and when i click a link in there, it opens a chosen folder on the computer, but i don't want it to open on just this computer's path, I wanted to open a folder that is inside the main folder, so that anyone that has the same files as I do, can open it, i tried < a href="File_path">, tried putting < a href="file:///(file path)">, tried like i have in excel ../../'file path', and can't see where is the problem, anyone can help?
Here you need to use a "file" protocol to link a file in the HTML like,
Link
The browser may or may not open the file due to the security setting. You can click the right button and choose "copy link address" and then paste it into the browser.
There are security implications of showing a local file/folder from an website. It may work when the page is held locally but when on a server it will be failing. However definitely not any chosen folder anywhere in your PC.
If you require to achieve such you need custom implementation using a programming language like ASP .NET like shown in this example.
https://stackoverflow.com/a/6047826/684030
You haven't mention much details on what web server you are using. But if it's IIS (Windows) you may consider allowing directory browsing which may allow to show a sub directory under your website.

Get downloadhistory from Selenium

Is there any way I can find out what the latest file Selenium downloaded was, and from where (what URL) it was downloaded?
I am fetching files from a large number of sites (that I do not control) by clicking on elements, and my problem is that I do not know how the files are downloaded. Sometimes it is just an <a> element, sometimes there is a Javascript event attached to some element, or form (not always obvious from inspection), and so on, and so on.
So I though the easiest would be to just do my clicks, and then check what landed in the download folder. But then I have no idea where that file came from, and I also need to store the url.
For files that can be displayed inline, I can, of course, open them in the browser and get the driver.current_url. This is very convenient for file formats where it actually works, so if there is a way to force e.g. Firefox or Chrome to open all files inline, that would also be an option. (I am aware of one such extension. That extension, however, requires some user interaction in a OS file dialogue window, and that seems like overkill here)
Possible solutions
Firefox: Read moz_downloads from downloads.sqlite, in the FF SQLite DB
Chrome: Read the corresponding SQLite db for Chrome/ium
Write browser extensions that modifies the mimetype of visited pages, so that all files are opened as plain in the browser, and the URLs can be accessed from there.
How I understanding selenium it only insert js to page, that mean that you can interact only with web page but not with browser futures.
But you can do like in this post How to access Google Chrome browser history programmatically on local machine if that files are in download history you can find them there.

Download .html file as attachment instead of opening

When I send a .html file as an attachment it opens in a new browser tab when it is clicked on. I want it to download as normal attachments are.
Is there a solution to this problem. Perhaps a programming solution? Or perhaps a file extension that downloads from emails but opens normally in a browser when clicked on?
I know that the recipient can right click and click download or something but I want the sender to be able to control whether or not it is downloaded or opened in a new tab.
Does a file extension that opens with browsers by default but downloads normally from emails exist?
Your webserver is sending a content-type header of type "text/html", and your clients' browsers are acting on that header. If you can tell your server to send "application/octet-stream", then the browsers will ask the users what to do with the file.
Maybe try changing the file extension to .php might work. PHP files are basically html files, but they expect PHP code in there - doesn't mean there has to be though. (This may work for other code language extensions too).
Not sure if the whole workflow will play out the way you want it, but worth a try...

How to make download PDF html code download on computer

I'm creating a button which will download an original file in a PDF format. I already have a zoom button if they want to read the PDF via the browser. But I want to offer the possibility to the user to download the file if he prefers, obviously the downloadable file will have a higher quality.
I've tried some basic coding but the problem is that the PDF is opened in the browser. I'm not using any CMS and won't in a future, so the photos are uploaded simply via html code and by placing the picture in the correct file, so no database is present. This is the code I'm using in this moment:
<img class="icons_infobox" src="./_img/prensa/icon_download.png" alt="Download original file" />
This website needs to be cross-browser compatible so I also will ask the answer to be browser friendly.
Thank you very much!
Hello curious people!!!
After gathering and investigating what could be done I've found some answer. I will give as an answer only two options:
100% sure it downloads but not so nice for the user
-Only sure way is converting the downloadable files into .zip. Yes its not too handy/elegant but that is for sure the way the browser will be obliged to download this file. ZIP format files are always downloaded.
Depends of the users browser preferences
-Yes, you cannot be completely sure but its a very close approach. You will need to create a .htaccess file in the folder where you have your PDF for download. You would need to create this file and place it in with the following code:
SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf
Header add Content-Disposition "attachment" env=requested_pdf
I hope this helps somebody. In my web it did work perfectly. It divers between browsers but it works... You just need to know that there will be a porcentage that will see it displayed in the browser and not downloaded.
Greeeeetings,
Dani

Legitimate technique for avoiding file download blocker in IE ("To help protect your security")?

My web app allows export of data in a variety of formats. The export is triggered by selecting an export format from a dropdown (<select>), which causes the form to be POSTed and the file returned and downloaded in the requested export format.
This works fine on all browsers except for IE - on IE the "To help protect your security" blocker appears, and clicking on the "Click here for options" causes the page to reload instead of allowing the actual download.
In short IE users can't download files due to the blocker and the subsequent reload instead of download.
I know we can ask users to change their security zone settings to enable download, but for a variety of reasons this is not practical - there are a lot of users in a lot of different environments and they tend to ignore instructions.
Are the rules for what causes the blocker to come up documented somewhere? What's the legitimate, recommended way of allowing file downloads in IE? That is, for the scenario detailed below, how can I setup the HTML/form to actually let the user download the file?
Show the user a list of file formats
Once the user selects a file, download it to her computer without triggering the download blocker on IE
Have your <select> block simply inject (using JavaScript) click here to download text somewhere else in the DOM tree. Then, the user clicks on a standard link and it reloads the full page, downloading the file directly.
You can even have the click to cause GET requests..