Hi all. As part of my website, I need to allow users to download a large number of files (images and MS Office documents mainly). All the files are stored in a folder called /userFiles and to open them, users are directed to a link 'userFiles/openFile.php?file=FILEID&code=FILECODE' where the unique file code must match up to the file id for the user to have access. This is a way of ensuring not anyone gets to protected files.
After access is verified, the following bit of code is run:
$contentType = filetype($fid . $ext);
header("Content-Type: $contentType\n");
header("Content-Disposition: attachment; filename=".basename($name . $ext));
readfile($fid . $ext);
This pops up awindow that enables users to either 'open' or 'save' the file they are trying to download.
Here is the problem- it seems the file is downloaded to temporary memory BEFORE the pop up even appears. This isn't a problem for little word or text documents, but for 2 or 3mb images, it means that the user doesn't know what's going on for quite some time.
Is there any way to fix this that you guys might see?