473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do I protect the pdf files from unauthorized users?

logudotcom
How do I protect the pdf files from unauthorized users. I want to protect the pdf files from direct access.

The aim is to hide the name of the file either when mouse over and in the source of the file but on the user side they dont want to have other click or input, the file should be directly open in a new tab or new window.

Is there any suggestions please?
Mar 17 '09 #1
9 3703
Dormilich
8,658 Expert Mod 8TB
you could password-protect the directory where your PDFs reside (using .htaccess) but the more elegant way would be adding the links to these PDFs only for registered/logged in users (e.g. using a session) (you can't access what you don't know).
Mar 17 '09 #2
Hi,

I can check it with logged user session. also with download.php to hide the path.

But at the same time, I want to open it in the new window or tab? Is it possible from the browser itself to force to open the pdf
Mar 17 '09 #3
When I use download.php & session, is is fine.. but how do I force to open in the browser?
Mar 17 '09 #4
Dormilich
8,658 Expert Mod 8TB
if the browser knows the file type (e.g. image/jpeg) it looks for the default action (somewhere in the settings). if it is not forced to download it will try to open it in a window (or tab, depending on the user's settings).
Mar 17 '09 #5
No other way to change it through programming...
Mar 17 '09 #6
Dormilich
8,658 Expert Mod 8TB
you cannot control everything in the browser. Users would get very annoyed if their browser doesn't work like they want.

(shouldn't your problem be solved once you get the downloads forced?)
Mar 17 '09 #7
My problem is "
user side they dont want to have other click or input, the file should be directly open in a new tab or new window " ...
Mar 17 '09 #8
Dormilich
8,658 Expert Mod 8TB
through what shall the download/opening be triggered?
Mar 17 '09 #9
if ($_SESSION['user_id'])
{

$dir_path = '/dirs/';
$filepath = $dir_path.$_GET['filename'];
$file_type = filetype($filepath);
$filesize = filesize($filepath);

header("Content-type: ". $file_type);
header("Content-length: $filesize");
header("Content-Disposition: attachment; filename=$filename");

$handle = fopen($filepath, "r");
$contents = fread($handle, filesize($filepath));
fclose($handle);
echo $contents;
}
Mar 17 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gabriel | last post by:
Hello everybody. I have a question about how to protect my PHP-script from all unauthorized access. I have a PHP-script on my web server and this PHP-script should only be accessible from _one_...
2
by: travelling_nerd | last post by:
Folks: I have some zip files I'd like to serve to authenticated users on my site, but would like to prevent unauthorized users from using an absolute path to get to these zip files. For example...
5
by: Martin Franklin | last post by:
I have a simple 2 page frameset that I am trying to protect using asp. I've included the following code listed below at the top of each page including the frameset page in an attempt to protect...
5
by: Brian Madden | last post by:
Hello All, I have what I thought would be a simple problem although I've been searching for a few hours with no luck. I have several PDF and MPG files I would like to provide to users to...
11
by: siliconmike | last post by:
Is there a way to protect data files from access by root ? I have a data-centered website and would like to protect data piracy from any foot-loose hosting company employee. Any ideas? ...
3
by: Parham | last post by:
Hello, How to protect structures(Tables,SP,Views and Functions) of a SQL Server Database?(Password protect a database file) I have a SQL database that will distribute with my application, I want...
5
by: Ronald S. Cook | last post by:
Using Forms Authentication, users can't get to my .aspx pages but they can get directly to, for example, Setup.exe. What setting can I use to protect ALL files within my app from hackers...
0
by: Bank of America | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
12
by: =?Utf-8?B?am9uaWdy?= | last post by:
I wrote a simple VB.NET application that imports and edits CSV files. Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be opened separately. It is not high-sensitive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.