- Jquery Download File Without Redirect
- Jquery Download File From Server
- Jquery Download File From Url And Save
How can I prompt a download for a user when they click a link.
For example, instead of:
I could use:
This way, Google does not index my HREF's and private files.
Can this be done with jQuery, if so, how? Or should this be done with PHP or something instead?RedBlueThing
I might suggest this, as a more gracefully degrading solution, using
If you don't want search engines to index certain files, you can use robots.txt to tell web spiders not to access certain parts of your website.
Here's a nice article that shows many ways of hiding files from search engines:
An easy fix is to add the
rel='nofollow' attribute, though again, it's not complete without robots.txt.
Yes, you would have to change the window.location.href to the url of the file you would want to download.MacAnthonyMacAnthony
window.location.href = 'uploads/file.doc'; you show where you store your files. You might of course use .htacess to force the required behaviour for stored files, but this might not always be handful....
It is better to create a server side php-file and place this content in it:
This code will return ANY file as a download without showing where you actually store it.
You open this php-file via
window.location.href = 'scripts/this_php_file.php?f=downloaded_file';
Jquery Download File Without Redirectletronje
I suggest you use the mousedown event, which is called BEFORE the click event.That way, the browser handles the click event naturally, which avoids any code weirdness:lingling
See here for a similar post on using jQuery to clear forms: Resetting a multi-stage form with jQuery
You may also be running into an issue where the values are being repopulated by the struts value stack. In other words, you submit your form, do whatever in the action class, but do not clear the related field values in the action class. In this scenario the form would appear to maintain the values you previously submitted. If you are persisting these in some way, just null each field value in your action class after persisting and prior to returning SUCCESS.
Jquery Download File From Server
Jquery Download File From Url And Save
protected by karim79Aug 9 '11 at 1:51
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?