473,511 Members | 10,974 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
file.
I'd like to write something like that:

<a href="download_file.php?id=1123">download file</a>

download_file.php get the file and give it to user.
BUT...
.... how can I write download_file.php?
thank you in advance for your help,
Andrea.
Jul 17 '05 #1
5 7748
*** _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
file.
Downloading a file from a hidden URL is like calling someone whose phone
number is unknown...

... how can I write download_file.php?


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():
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

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

// The PDF source is in original.pdf
readfile('original.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.it> wrote:
I'd like to let user download a file but I'd like to hide the url of the
file.
I'd like to write something like that:

<a href="download_file.php?id=1123">download file</a>

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


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

--
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
file.


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

--
Jock
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(strtolower($fname)))
{
case 'myfile1':
$file = 'private/file1.zip'; break;
case 'myfile2':
$file = 'private/file2.zip'; break;
default:
Location("downloadinvalid.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) .
"\n\n");
readfile($file);
?>
usage:
download.php?fname=myfile1

Jul 17 '05 #6

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

Similar topics

2
10999
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...
4
18830
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...
2
330
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...
2
1859
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...
1
2260
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...
13
1812
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"...
1
2639
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...
3
4015
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() { ...
0
10707
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...
0
7144
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...
0
7356
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
7512
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
5671
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 project—planning, coding, testing,...
0
4741
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...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
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 ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
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...

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.