RLJ Posted August 29, 2011 Share Posted August 29, 2011 Hi all, This is probably a very basic question, but it's the first time I've had to deal with it and I can't find a direct answer anywhere online. I have blocked direct access to a file that a user has uploaded in the Apache configuration and in the .htaccess file, so that the file is only accessible through a viewing (PHP) script, which will determine whether the access is allowed or not depending on several factors. What is the actual code I need to give access? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/245953-file-viewing-script/ Share on other sites More sharing options...
RLJ Posted August 29, 2011 Author Share Posted August 29, 2011 just to clarify, code as in PHP code. I.e. what's the PHP script I need to give access to a file where direct access has been blocked. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/245953-file-viewing-script/#findComment-1263303 Share on other sites More sharing options...
requinix Posted August 29, 2011 Share Posted August 29, 2011 Code as in "give me the code to do this"? I sure hope not. The bare minimum is 1. Figure out what file the script is supposed to send 2. Make sure the file is okay to send (was uploaded, right file type, etc) 3. Figure out the type of file (JPEG image, PDF document, etc) 4. header("Content-Type: $filetype"); // image/jpeg, application/pdf, etc readfile($filename); Quote Link to comment https://forums.phpfreaks.com/topic/245953-file-viewing-script/#findComment-1263331 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.