473,671 Members | 2,290 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=112 3">download file</a>

download_file.p hp get the file and give it to user.
BUT...
.... how can I write download_file.p hp?
thank you in advance for your help,
Andrea.
Jul 17 '05 #1
5 7767
*** _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.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():
<?php
// 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
file.
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.
BUT...
... 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
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(str tolower($fname) ))
{
case 'myfile1':
$file = 'private/file1.zip'; break;
case 'myfile2':
$file = 'private/file2.zip'; break;
default:
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) .
"\n\n");
readfile($file) ;
?>
usage:
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

2
11006
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/, and /www/ht/ is the root web directory. So I put "conn.php" in the inlcude directory...
4
18849
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 better way to hide/encrypt this, without to removing status bar.
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 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 this. Thanks
2
1874
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?
1
2264
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
13
1830
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 secured- folder to a temp-folder and renames it to some random file-name that the user can download....
1
2644
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 (Fire fox, safari, opera) with a simple call from my asp.net 2.0 page to a JavaScript function that
3
4030
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...
0
10753
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 a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8473
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8911
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8667
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.