how to know browser download location programatically - javascript

I have a webpage, that downloads a file,
now the requirement is to show a alert where the downloaded file has been stored.
Is it possible to get the download folder location of a browser through any of browser properties(navigator,window,location etc). Please help.
Thanks in advance

Nope, it is not possible.
Paths, and the whole HDD are beyond browser sandbox, you can't even got the choosen path from "Pick file to upload" (<input type="file"...) buttons.

If it's a normal webpage then forget about it as #ProblemFactory says. But if it's a webapp for closed group of users and you can enforce to use a specific browser then you can achieve this goal by creating a browser extension. At least I know it's possible in Firefox.
And here is the documentation of API https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download
The target property of the Download object holds the path to the file.
As you said that you are using IE9, I assume that the choice of the browser is up to you.

Related

How to read a Bookmarklet from java?

There is a Javascript that needs to be executed after hitting the page in the browser. This javascript runs only when it is stored as a bookmark in the browser. My task is to execute this javascript that is stored in the bookmark in the browser using a java code.
On Googling, I find that the URL can be bookmarked via a java code. But I dont find how to read the bookmark. Please suggest how can I read it through java code.
Thanks in advance!
There is an answer which said that is impossible to do it unless you do a browser extension:
Get browser bookmarks via javascript
Although another answer talks about upload the browser bookmark file and read it in javascript :
Inside the "...\Chrome\User Data\Default\" directory are two files. "Bookmarks", and "Bookmarks.bak". One is for your current bookmarks, and the other one (with the .bak extension) signifies that it is a bookmarks backup, if anything goes wrong. Bookmarks.bak gets overwritten every time you close Chrome.
Bookmarks in Chrome exist as a virtual filesystem. Meaning, that all
your bookmarks are really just stored in one file, but appear as an
actual filesystem inside Chrome.
You only have to copy that file, and back it up somewhere. And if you
want to recovery your bookmarks, simply copy/paste the "Bookmarks"
file you backed-up, back in to the directory you took it from.
Chrome must be closed prior to doing this.
Hope this helps.
(and btw, try opening the "Bookmarks" file with a text editor like
Notepad =])
Location of chrome bookmarks

Get absolute file path in html/javascript

I need to let the user browse a absolute file path and set that path into a text-box.
Please note: I know you donĀ“t need the path to upload the file and I will not actually upload the file. This is for internal use in an intranet where the user needs to enter a path to a file.
What I need is a button that opens a browser and a text box that shows the result. Sound easy but the input file control only gives the name of the file and I cannot find a solution.
This is, alas, not possible for security reasons. Javascript has very limited access to the filesystem.
See http://msdn.microsoft.com/en-us/library/ms535128.aspx for IE specific workaround, and http://dev.w3.org/2006/webapi/FileAPI/ for info about what is coming in html5 wrt. file uploads.

How to save indirectly loaded images from webpages

I know that most of the media in web pages are temporarily stored to a temp folder or browser cache. Some are directly embedded in web pages so that we can see the source and can save them. But how to save images loaded using any other method?
You can see what I am talking about here. Is there any solution to save images from this site's gallery?
Yes there is a way to save the images by using the followings
1) Mozilla Firefox
2) Firebug
open the net console in it and select the tab named images
in that u can see all the images and save the images
for your reference, I attached a image.
then copy the location by right click and paste the location
and get the image.
~~~~~~ Happy Coding ~~~~~~~~~~~
Generally, js can't hold the image itself. but the Attribute src, a string instead. And js cannot handle the file on client, you can't modify, move, or copy files. So if you want to keep the images, you can send a http header like if-Modified-Since on server side with php or java, then the browser will not load the image again.
May this will help you. Good Luck!
You could try to use a offline browser.
They save whole webpages and deeping on software they catch more or less.
Offline Browsers

html + javascript: Browsing a folder using browse option

I need to have my user send the file path to the webserver. For this i'm trying to use input file type so that user can select the file. Please note that I don't want do uploading the file. I just need the location of some file. So user should be able to do that using browse option. I know that due to some security reasons in browsers, full path is not sent to server. But can we acheive this some way. I've observed that using input type=file after user selects some file using browse option (as it is not possible to select folder), the Firefox sends the server just the filename and IE sends fullpath of file including file name.
Please note that this website is used internally so it is not a security problem at all, so don't bother about security and all.
is there anyway we can acheive this?
Thanks in advance,
Sreed
You need to use something that has access to the filesystem. BY DESIGN javascript/html cannot do this. You need to use flash, java or a browser plug-in.
No, sadly I don't think there is.
All modern browsers will send a C:\Fakepath path. To my knowledge, this behaviour can not be changed for local networks in any browser.
I'm not sure what the state of things is for Flash-based uploaders like SWFUpload or Uploadify. Flash traditionally gives more control over such data than the native browser controls. (Edit: Uploadify seems to give you the file path. See this question: How can I get the uploaded file details from uploadify after completion however, this of course is after a completed upload, which is not what you want.)
A Java applet based solution will be able to do this, but I expect the effort to implement this is huge.
I would consider using a normal text file, and asking the user to just copy+paste the correct path.
Browsers do not let you save or even see the full file path to a selected file from the <input type="file" /> form element. I would recommend Flash or Java for your needs. You could also have the user manually type in the full path...just a thought.

Is it possible to open a file from a shared folder outside the browser

We have a file handling ASP.Net web control used in intranet web applications, that currently uses ActiveX to handle file check-outs, and check-ins. Works fine, in IE&Win.
But now we are trying to get rid of ActiveX & IE only behavior...
If a file is checked out, it is copied to file share, with access right limited to the checking-out user.
Using a hidden iframe, and setting the src of the iframe to something like "file:////file_share/dictionary/users_stuff/someDoc.doc", an open/download dialog is shown, so the user can open and edit the shared file in Word, Excel, etc directly from the file share.
Works fine for file types browsers can't handle themselves.
But for file types like txt, images, html the browser simply loads the file to the iframe, or opens the file, if the user is given a link. And the user can't edit the file without manually launching the appropriate application and copying the url. Showing the users a "Copy this url to your preferred application, and try to edit it" would not be really user friendly...
My question is: is it possible to get the browser (without ActiveX, IE...) to pass the link to the OS, or show a "What do you want to do with this file" dialog of some sort?
If not, what and how could be achieved?
The closest I could come up with is this thread:
https://stackoverflow.com/a/1394725/1195927
#Red says no (and the original poster agrees) BUT #Daan seems to have a solution.
I have not tested, so YMMV.
If a javascript/html solution is not found, I may have an ugly hack for you . . .
See my post here: Launching a Downloadable Link

Categories