473,569 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to hide the url of a file for download

I'd like to let user download a file but I'd like to hide the url of the
I'd like to write something like that:

<a href="download_ file.php?id=112 3">download file</a>

download_file.p hp get the file and give it to user.
.... how can I write download_file.p hp?
thank you in advance for your help,
Jul 17 '05 #1
5 7758
*** _andrea.l wrote/escribió (Fri, 01 Jul 2005 07:59:43 GMT):
I'd like to let user download a file but I'd like to hide the url of the
Downloading a file from a hidden URL is like calling someone whose phone
number is unknown...

... how can I write download_file.p hp?

Given that what you really want to know is how to write a download script,
I've found this example in the manual page for header():
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downl oaded.pdf"');

// The PDF source is in original.pdf
readfile('origi nal.pdf');
It shouldn't be difficult to write a generalization.

-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
Jul 17 '05 #2
On 2005-07-01, _andrea.l <an************ ******@libero.i t> wrote:
I'd like to let user download a file but I'd like to hide the url of the
I'd like to write something like that:

<a href="download_ file.php?id=112 3">download file</a>

download_file.p hp get the file and give it to user.
... how can I write download_file.p hp?
thank you in advance for your help,

You could start a session on the previous page, and store $file in

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Jul 17 '05 #3
_andrea.l wrote:
I'd like to let user download a file but I'd like to hide the url of the

Are you positive all your visitors are up for a game of hide
and seek, _andrea.1?

Jul 17 '05 #4
restrict the download to a "logged in" user?

Jul 17 '05 #5
download.php ...

set_time_limit( 600); // 600 secs (10 mins) maximum transfer

$fname = $_GET["fname"];

switch(trim(str tolower($fname) ))
case 'myfile1':
$file = 'private/file1.zip'; break;
case 'myfile2':
$file = 'private/file2.zip'; break;
Location("downl oadinvalid.php" ); exit;

header ("Pragma: no-cache"); // HTTP/1.0
header('Content-Description: File Transfer\n');
header("Content-type: application/octect-stream\n");
header('Content-Length: ' . filesize($file) . "\n");
header('Content-Transfer-Encoding: binary\n');
header('Content-Disposition: attachment; filename=' . basename($file) .
readfile($file) ;
download.php?fn ame=myfile1

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: NotGiven | last post by:
I have the following at the beginning of the PHP page: <?php require_once('Connections/conn.php'); ?> I want to hide the connection file, "conn.php", so it's out of the web accessible file structure. I understand putting them in the php include directory shoudl do this. For example, let's say the directory I put them in is /www/phpIN/,...
by: Atz | last post by:
<a href="" onmousedown="setTimeout('status=\'Hide\'',5000)" onmouseover="window.status='Hide'; return true"> send link </a> I use this for hidding link path in status bar. This is working fine but if u click "fast" many times on same link you can easy read path link and variables. I try to change timeout time but no effect. Is there a...
by: R.A. | last post by:
Hi In the web site I work on I give the users an option to download files from the web server. They click a button and I use the Response.Redirect("filename.exe"). The problem is that the user migth see the downloaded file url. Is there a way to hide the downloaded file url (it shows in the ie taskbar). Server.Transfer doesn't work for...
by: zhangyl | last post by:
I use a WebBrowser control to open an office Document in my form , but every time when I open a file, there a dialogbox named "File download" showed asking "Whether you want open or save this file?", how can I hide it? Actually, when opening an office file embeded in IE, there also show this dialog, How can I do it?
by: bonnijose | last post by:
good morning to all, i am uploading my "First" web server files today. for security reasons can anyone using the internet see "ALL" the files in my web server account? i mean, if someone type http://www.xxxxxxx.com then he would see my
by: nokan | last post by:
Hello! I'm trying to secure pdf-files from users that are not logged in on a site. What I have tried now is to make a .htaccess file in the directory where the pdf's are with "deny from all" which stops everyone from downloading them. Then in the member-area when a user wants to download a pdf a php-script copies the pdf-file from the...
by: axelman | last post by:
Hi everybody, sorry if this seems stupid but I'm a newbie :-( to all of this. I'm trying to hide the full file path in IE7 and IE6 while a user clicks on alink on my page and downloads a file from my server, just want to open the file download box but the path must remain invisible. I've achieved this successfully in all other browsers...
by: jmeyer5csc | last post by:
i am using jquery to display a working... div to show the user that the query is doing something. to show.... Sys.Application.add_init(function() { $addHandler($get('ctl00_ContentPlaceHolder1_LinkButtonQuickReport'), 'click', function() { $('#working').show(); }); }); to hide...
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not...
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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.