Can i restrict a file to direct download.suppose in my domain i am having a upload folder in which i am having a exam.pdf file then it should not be downloaded by accessing url http://www.mydomain.com/upload/exam.pdf . If it is possible then please tell me the way.
daniel36
-7
Light Poster
Recommended Answers
Jump to PostIf you are using Apache web server then use an .htaccess file, with this directive:
order allow,deny deny from all
put this inside upload directory.
Jump to PostIf you deny direct access then you need a script to display file names and to provide a download option. For example:
<?php $files = glob('./upload/*.*'); print_r($files); # print array ?>
All 5 Replies
cereal
1,524
Nearly a Senior Poster
Featured Poster
daniel36
-7
Light Poster
daniel36
-7
Light Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
sDJh
39
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.