Django Python does not display the correct PDF file -


i have pdf files stored on server. writing code prompts users download pdf file. used following code:

filename ="somepdf.pdf" filedir = "media/" filepath = os.path.join( filedir, filename )  pdf=open(filepath) response = httpresponse(pdf.read(),content_type='application/pdf') response['content-disposition'] = 'attachment;filename=%s' % filename return response 

for reason, rechecked pdf file prompted. pdf file not readable (corrupted file perhaps).

do know happen?

you have missed media_root:

from settings import media_root ... filepath = os.path.join(media_root, filedir, filename) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -