Jump to content

[SOLVED] Present document outside of web path for download


JD*

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.