Writing a small app that (among other things) lets users upload a file (like an image, a .doc or a text file) as part of their posting/submission.
You have to do the following:
$id.$ext
and so on. In short, you don't want to use the user's file name in your system.download.php
or whatever, get the file's ID, verify who is logged in, and if everything checks out, fetch the file, read it out to the browser, and send the appropriate download headers.These headers would be something like:
header('Content-type: application/octet-stream');
header('Content-disposition: attachment; filename=usersuppliedname.txt');
header("Content-Length: " . filesize('../safefiles/1.txt'));
header("Content-Transfer-Encoding: binary");
readfile('../safefiles/1.txt');
exit;
You can then get more fancy if you want to allow resuming files and such, but the above should do it.