force download file with a download box using ActiveXObject("WScript.Shell") - vbscript

could anyone please give me an example on how to force to show the save box using ActiveXObject("WScript.Shell"), without php or other stuff !?
i would like to allow to download some mp3 file, instead those are being opened directly in the windows media player..
i just want to give the user the chance to choose whether download them or just open them
thanks a lot in advance

You need to use the Content-Disposition HTTP header in your web page. It's the cross-browser supported method for forcing a SaveAs dialog to appear.
http://www.jtricks.com/bits/content_disposition.html

Related

Saving a file from an URL with WebBrowser with VB6

I have a project with VB6.
I need download a file from an URL. Then I use WebBrowser:
WebBrowser.Navigate "www.miurl.com/mifoto.jpg"
I need save mifoto.jpg directly to my path, I don't need any question about where I save it.
But WebBrowser always asks me to save it.
check this link it may be what you're looking for... I'd expect something like this may be best to do through the Windows API:
http://vbnet.mvps.org/index.html?code/internet/urldownloadtofile.htm
if you want to use the WebBrowser control I think there are a few properties that may help: Silent and Theater

View or Open in Browser vs. Download

I am using HTML and CSS, and willing to use a very simple JavaScript code if necessary.
I uploaded ResumeWord.doc and ResumePDF.pdf to the FTP. I created links for "View" "Download" and "Print" for each. ResumeWord.doc only seems to give me a pop-up with options to Open or Save instead of opening in the browser, while I was able to open ResumePDF.pdf in the browser but not create a clickable link to download it without viewing. I have tried the HTML target_blank and JavaScript window.open for the "View", unsuccessfully. I am self-taught and an amatuer.
How can I make the "View" link open ResumeWord.pdf in the browser without a pop-up?
How can I get ResumePDF.pdf to download when the user clicks "Download"?
Without some help, the browser won't assume that a user has Microsoft Word installed on their computer. That is why you only get the option to save it, rather than it opening.
The PDF, however, is something that can be viewed in-browser, and the browser can check if the right files are installed to make this happen. So if they are, the browser goes ahead and opens the file.
As for forcing the browser to open a word file, see this SO question.
And as for forcing a download of a PDF, see this SO question. It may not be possible, in your case, as the solution involves sending different server-side headers.

Microsoft Security login box when downloading Word document

I've looked around online for this but can't seem to find an answer anywhere so hopefully someone can help.
I'm getting a "Windows Security" popup appearing on a site I've created (and so are others which is who I need to fix it for rather than myself) when trying to download a word document or excel file. PDFs seem fine.
An example page is http://www.christletonhigh.co.uk/school_information/uniform.php if you click to download the “Uniform Prices & Order Form” in the bottom right.
There’s no SSL on the site and the error only comes up on IE (I'm using IE9 on Windows 7 which I've seen others mentioning online as their setup with this happeneding) and doesn’t seem to effect all files so it’s a bit confusing. Clicking cancel on the popup causes the document to open anyway.
Anyone have any ideas please? The client tells me that the documents causing the problems have never been password protected.
For the reference, here's the detailed explanation why this happens: http://support.microsoft.com/kb/2019105
Solution mentioned by Anshuman should work: create script that adds "Content-Disposition" header with "attachment" value. For example: Content-Disposition: attachment; filename="myfile.doc". This will force all the content (including PDF, images, etc.) to be downloaded.
Security settings aside, other browsers seem to handle this more gracefully than IE9. Chrome, for example, seems to handle the download of the document with ease, and not result in a Windows Security dialog prompting for credentials to their network...
The users can disabled the 'protected view' settings from Word options | Trust Center, and the document will open with no dialog (probably not desirable to instruct them to do this)
I suppose this is the risk one takes when having users download content which require other applications to handle. a PDF would be better (hence the "P" for "Portable"), so if they can use PDF, that would be my first advice.
This issue comes when you give the direct URL path of the file and let the browser handle the file. To resolve this create a php script that explicitly downloads the file. Hope this helps :)

File Downloading

We are working on our converter site. and we want users to download their converted file. But audio files and other files are just playing on the browser, How can we set all Video/Audio formats downloadable (not just because the browser supports the player for the formats). THANKS.
IMO you should check the MIME types. I think if you set it as binary, it will get downloaded, not played by the browser.
Another approach is to put the file(s) into an archive server side then attach the archive to the response. That way you avoid client playback and potentially decrease download time.
Another possibility is, as most sites do, just show the link and instruct the user to right click and select download. I'd go with other options (as proposed, like looking into the MIME types), but it is still another possibility.

In a firefox extension how to save a copy of a pdf opened in the browser window

I have a Firefox extension and in some cases when a user navigates to a PDF I'd like to save a copy of the file. This is easy when the PDF is downloaded (as I can use nsIObserverService to get the file), but when the PDF is opened in the browser using the Adobe Reader plugin I can't see how to get the file without downloading it again. Any ideas?
The plugin or firefox seems to wrap the pdf in html that contains a single EMBED tag with the pdf. So I can get the embedded object via doc.embeds[0] but don't know if there's any available interface to do anything with that.
An alternative would be to use something like nsIObserverService to notice when a file has been retrieved for viewing - but I don't know if that's possible?
I don't want to simply get the url and re-retrieve it, as it will sometimes no longer be available, having been served from a web app.
thanks!
UPDATE: to clarify, I want my firefox extension to do this in code, not by pressing CTRL+S as a user.
If the pdf is opened using the Adobe Reader plugin you can simply click on the Save icon on the reader tool bar. That is the easiest way.
Press Ctrl+S
In the pop up window select the location to save the file and press Save.

Resources