Download links to files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Download links to files

Post by LonelyProgrammer »

Hi,

I am currently hosting binary format of a game save files on my server. The strange thing is, I have to give Execute right to Public, User and Owner for upload folder before others can download it. How can I serve the file to them from the upload folder without having to directly link to the upload folder?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Download links to files

Post by aceconcepts »

How about using an include and then within the include use an id to fetch the corresponding file from a database.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Download links to files

Post by Jonah Bron »

I believe you can make a php page that will 'return' the document, as it were.

Something around this type of thing, but I'm sure this right here doesn't work. I've never done it before:

Code: Select all

<?php
$file = file_get_contents('the file address');
header('Content-type', 'the type of the file');
echo $file;
?>
Post Reply