Download file on button click






















Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. Please select a comment to reply. You can add your comment about this article using the form below. Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content.

Please do not post code, scripts or snippets. Required Invalid Email Address. Security code:. If you don't want search engines to index certain files, you can use robots. If you rely only on javascript, then some users who browse without it won't be able to click your links. JavaScript isn't a good way not to index a page; it won't prevent users from linking directly to your files and thus revealing it to crawlers , and as Rob mentioned, wouldn't work for all users.

Yes, you would have to change the window. By stating window. You might of course use. You open this php-file via window. Hidden iframes can help. That way, the browser handles the click event naturally, which avoids any code weirdness:. 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.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 12 years, 3 months ago. Active 5 months ago. Viewed k times. How can I prompt a download for a user when they click a link. Can this be done with jQuery, if so, how? Or should this be done with PHP or something instead? I created a button and made onClick event in C. Now, which code should I write to do that? Improve this question.

Is that an asp button or just a html button? Can you post the relevant code? I want the it's download the file in this path , but stay in the same Location. I've added the server-side part. If you have an ASP. NET button tell so, you'll be able to do this easier. Add a comment. Active Oldest Votes. I think you are looking for something like this. TransmitFile Server.

Improve this answer. Krishanu Dey Krishanu Dey 6, 6 6 gold badges 48 48 silver badges 67 67 bronze badges. HI, i try that but when I click the button nothing happen. I check with debbuger and it's enter to the event and run on this lines..

InnerText; Response. MapPath x ; Response. End ; — Krishanu Dey. I've created a dummy website. The problem was that I placed my button into UpdatePanel , not I put it outside the element and it's work. Thank you!



0コメント

  • 1000 / 1000