Ask a Question related to PHP Development, Design and Development.
-
Robert Peake #1
Re: download from secure archive
Hi Dani,
PHP isn't really designed to interact with the filesystem in the same
way that a proper htacess scheme would work. One alternative is to
"bury" your files in a directory no-one is going to type in manually,
like:
[url]http://www.yourfreehost.com/~yoursite/subdirectory/2034820482309810940921834/[/url]
Then, you can put a PHP file in the subdirectory that takes in the
file to download, like
[url]http://www.yourfreehost.com/~yoursite/subdirectory/downloader.php?file=doc1.doc[/url]
and have the downloader.php file get doc1.doc from the
2034820482309810940921834 directory and stream its output. The
"gotcha" in all this is, of course, you need to make sure you return
the right mime types so that the receiving browser gets a *.doc file
instead of a php file. Something like:
<?PHP header("Content-Type: application/vnd.ms-word"); ?>
<?PHP header("Content-disposition: attachment; filename=doc1.doc"); ?>
should do the trick in the above example.
Cheers,
Robert
[email]Robert@PeakePro.com[/email]
[url]http://www.peakepro.com[/url]
[email]jeckyll@virgilio.it[/email] (Daniele) wrote in message news:<940a6f3e.0307280121.2b2fb3e3@posting.google. com>...> Hi all,
> I'm doing a php web site, after implementing a sicure access to
> download some file stored in a web server folder. My site is in a free
> hosting server and I haven't rights to modify any web service
> configuaration to allow or deny access to specify folder. I'm looking
> for a secure method to hide the directory where are stored important
> documents in order to allow the access only to authorized person that
> are logged in the previous php page.
> Any Idea
>
> Thanks a lot in advance
>
> DaniRobert Peake Guest
-
Archive Download Server is Down!
I'm trying to download version 7 of Flash Player, but the server is down! Why? I can't install version 8 or any other version. What's the deal... -
Secure Area Download
Hi i have this site http://www.aprocre.org.ve you can see in the right top corner a login. Thats login is only for the members that can (when they... -
Secure FTP File download + c#
Hi I need the ability to download a file from a secure ftp sight using c#. Has anybody got free code or at least point me in the right direction.... -
SA-FileUp Secure Download Issue - Please HELP!
Hi Everyone, I was wondering if anyone has ever successfully used SA-FileUp's download feature. I am being forced to change from... -
Download secure web page
http://www.aspfaq.com/show.asp?id=2257 -
Daniele #2
Re: download from secure archive
Hi Robert thank you for your hints,
I tried to make a download manager so but it doesn't work.
My script is:
$file="mysubdir/myfile.doc";
if ($fd = fopen ($file, "r")){
$size=filesize($file);
$fname = basename ($file);
header("Pragma: ");
header("Cache-Control: ");
header("Content-Type: application/vnd.ms-word");
//header("Content-type: application/octet-stream"); <-- I also
tried this
header("Content-Disposition: attachment;
filename=\"".$fname."\"");
header("Content-length: $size");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
print $buffer;
}
fclose ($fd);
exit;
}
I tried also this:
$file="fileName.doc";
header("Pragma: ");
header("Cache-Control: ");
header("Content-Type: application/vnd.ms-word");
$fd = fopen($file,'r');
fpassthru($fd);
I get always the content of the file in the browser without prompting
the save file window.
Do you have any hint?
Thanks a lot
Dani
Daniele Guest
-
Robert Peake #3
Re: download from secure archive
Hi Danielle,
You can not test your code by typing in the URL directly. The content
and disposition headers will only work properly when called from a
link.
The following code:
<?PHP
if ($doc=="resume.doc") {
header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment; filename=$doc");
readfile("../resume.doc");
} else {
print "<a href=\"getdoc.php?doc=resume.doc\">click me</a>";
}
?>
lives on my site:
[url]http://www.peakepro.com/workbench/getdoc.php[/url]
open it up and click on the link to see how it works.
Cheers,
Robert
[email]Robert@PeakePro.com[/email]
[url]http://www.peakepro.com[/url]
Robert Peake Guest



Reply With Quote

