By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

reading/writing files

P: n/a
Hi,

I am trying to read a file and write into other file. if I do it for
simple text file, it works well.
but for pdfs or some other mime types, its failing.

actually main problem is i am uploading file using cgi, in this
process I am getting content of file, and I am
trying to save the file. I think I need to specify mimetype of file
somehow..?
any quick solutions? or need to google.

sandip
Nov 27 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
f1= open("file1.pdf", "rb")
x = f1.read()
open("file2.pdf", "wb").write(x)

works...

thanks
sandip

On Nov 27, 5:43 pm, sandipm <sandip.m...@gmail.comwrote:
Hi,

I am trying to read a file and write into other file. if I do it for
simple text file, it works well.
but for pdfs or some other mime types, its failing.

actually main problem is i am uploading file using cgi, in this
process I am getting content of file, and I am
trying to save the file. I think I need to specify mimetype of file
somehow..?
any quick solutions? or need to google.

sandip
Nov 27 '07 #2

P: n/a
On Nov 27, 7:14 am, sandipm <sandip.m...@gmail.comwrote:
f1= open("file1.pdf", "rb")
x = f1.read()
open("file2.pdf", "wb").write(x)

works...

thanks
sandip
You might also like:

http://pybrary.net/pyPdf/

Nov 27 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.