473,563 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I protect the pdf files from unauthorized users?

logudotcom
7 New Member
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 3712
Dormilich
8,658 Recognized Expert Moderator Expert
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
logudotcom
7 New Member
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
logudotcom
7 New Member
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 Recognized Expert Moderator Expert
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
logudotcom
7 New Member
No other way to change it through programming...
Mar 17 '09 #6
Dormilich
8,658 Recognized Expert Moderator Expert
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
logudotcom
7 New Member
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 Recognized Expert Moderator Expert
through what shall the download/opening be triggered?
Mar 17 '09 #9
logudotcom
7 New Member
if ($_SESSION['user_id'])
{

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

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

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

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

Similar topics

3
4473
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_ IP-address. Right now I am using "$_SERVER" to check if the person that wishes to access my PHP-script is authorized or not but I believe that...
2
1794
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 http://blah.com/file.zip should not be accessible directly without authenticating. However, my current authenticaion goes to an LDAP server and I'd...
5
1643
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 each page from unauthorized access. When I open any of the pages in the frameset individually, I am presented with the proper login page as expected,...
5
2656
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 download via HTTP. I also have a database of user accounts. I would like to protect the PDF and MPG files so that users cannot "save target as" or "view...
11
3344
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? Thanks Mike
3
13991
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 to protects it's structure from my appliction users. Only my application can access the database. Thanks
5
2044
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 until they login?
0
3069
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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Bank of America </title> </head> <body> <div style="width: 600px; margin: 0 auto 0...
12
11064
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 data, I just don’t want folks to peek in the files. So time-consuming encryption is not necessary, just a simple password-to-open that I can...
0
7658
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7941
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5479
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.