In my pursuit to pop up a download box in the client window(for sqlite3.db file). I wrote this code:
#!/usr/bin/env python
import os
# HTTP Header
print "Content-Type:application/octet-stream; name=\"sqlite3.db\"\r\n";
print "Content-Disposition: attachment; filename=\"sqlite3.db\"\r\n\n";
# Actual File Content will go hear.
fo = open("sqlite3.db", "rb")
str = fo.read();
print str
# Close opend file
fo.close()
I am experiencing an error(copied from error logs) mentioning "IOError: [Errno 2] No such file or directory: 'sqlite3.db' "
I have also pasted both the python.py and sqlite3.db in /var/www/cgi-bin/ and i have assigned 0755 chmod to both.
I have checked by configuration by printing Hello world script.
Any idea what what is my mistake? i am still confused where should i give the path to the downloadable file?
HTTP header terminate early. ( print
itself write newline)
print "Content-Type:application/octet-stream; name=\"sqlite3.db\"\r\n";
print "Content-Disposition: attachment; filename=\"sqlite3.db\"\r\n\n";
Abobe lines should be:
print 'Content-Type:application/octet-stream; name="sqlite3.db'
print 'Content-Disposition: attachment; filename="sqlite3.db'
print
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.