- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to raise a "File Download" Dialog Box in Python CGI Programming?
Sometimes, it is desired that you want to give option where a user can click a link and it will pop up a "File Download" dialogue box to the user instead of displaying actual content. This is very easy and can be achieved through HTTP header.
For example, if you want make a FileName file downloadable from a given link, then its syntax is as follows −
#!/usr/bin/python # HTTP Header print "Content-Type:application/octet-stream; name = \"FileName\"\r
"; print "Content-Disposition: attachment; filename = \"FileName\"\r
"; # Actual File Content will go here. fo = open("foo.txt", "rb") str = fo.read(); print str # Close opend file fo.close()
- How To Raise a "File Download" Dialog Box in Python?
- Raise a "File Download" Dialog Box using Perl
- Save File Dialog Box in Tkinter
- How do we do a file upload using Python CGI Programming?
- Access to file download dialog in Firefox in Selenium.
- How to do CGI programming in Python?
- How to setup cookies in Python CGI Programming?
- How to retrieve cookies in Python CGI Programming?
- How to configure Apache for Python CGI Programming?
- How do cookies work in Python CGI Programming?
- How to create a Confirmation Dialog Box in Java?
- How to pass Drop Down Box Data to Python CGI script?
- How to download a file using Node.js?
- How to create a Custom Dialog box on Android?
- Passing Drop Down Box Data to CGI Program in Python