d/l a file in a secure way
Moderator: General Moderators
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
d/l a file in a secure way
i want to d/l a file
but i dont wantto let the user where the file on the server
and to prevent from him d/l file that he is not
authorized to d/l
how cna i do that?
i see in some places that when u press a link the file is bein redirected from another place,given a long string that tells which file to d/l but
the user can't take that link and byhimself to d/l that
thnaks in advance
peleg
but i dont wantto let the user where the file on the server
and to prevent from him d/l file that he is not
authorized to d/l
how cna i do that?
i see in some places that when u press a link the file is bein redirected from another place,given a long string that tells which file to d/l but
the user can't take that link and byhimself to d/l that
thnaks in advance
peleg
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
create a download script that knows where it is, or how to find it. The download script passes the binary data of the file back to the browser. There are many threads here about forcing download.. check those out for details on how to write a download script. You can also read the [php_man]header[/php_man]() user comments and things..
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you tried this kinda stuff?^ from [php_man]header[/php_man]() documentation...
Code: Select all
<?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');
?>- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
thi is the code
Code: Select all
<?
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="Getting Started Guide.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
<?php
// We'll be outputting a PDF
header('Content-type: application/x-rar-compressed');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.rar"');
// The PDF source is in original.pdf
readfile('original.rar');
?>