JD* Posted May 18, 2009 Share Posted May 18, 2009 Hello all, Trying to see if this is easier than I think it is. I have a small web portal for teachers to upload documents for their current students to be archived over the course of their years. In order to semi-protect the documents, I'm storing them outside of the normal web path. What happens is that when a teacher logs in, it gets their current students, which she can then click on and see what documents have been uploaded for that student. What I'm a little confused about is how to let them click on the link and then get that document. I plan on having a function that will check their access one more time, to make sure they're allowed to see that student's document, and then finding it in the proper folder and acting like a normal PDF download (all docs are PDFs), but I'm not sure if I should use a complicated fopen, fread etc or if it's just as simple as changing the header to point to the file where it resides on the server. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/158624-solved-present-document-outside-of-web-path-for-download/ Share on other sites More sharing options...
RussellReal Posted May 18, 2009 Share Posted May 18, 2009 you need to access the file with PHP, you can't direct your user's client to the file.. and it isn't that hard say its 1 directory back from the website's base directory you'd just do $filename = '../'.$filename; and then fopen, fread, and then set the mimetype of the document and I think its uhm application/pdf or sumfin like that, using header() for example header('Content-Type: Application/PDF'); and then echo all the data you got from the file into the page and then the page should either act like a download of the pdf file, or open it in the web browser acrobat reader addon thingy Quote Link to comment https://forums.phpfreaks.com/topic/158624-solved-present-document-outside-of-web-path-for-download/#findComment-836591 Share on other sites More sharing options...
JD* Posted May 18, 2009 Author Share Posted May 18, 2009 Thought so, but it's been one of those days where I'm second guessing everything. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/158624-solved-present-document-outside-of-web-path-for-download/#findComment-836594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.