I'm trying to get details on a file and then output it using header(). Here's the header code:
header('Content-Type: '. $mimes[$ext] .'; filename="'. $fullpath .'"');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); /* fixes IE problem with opening PDFs (see ctemple comment on http://ca3.php.net/readfile) */
header("Content-Length: ".@filesize($fullpath));
readfile($fullpath);
exit;
Now this is working for filenames like "test.txt", "file.jpg", "document.doc", etc. When I tried it on a file called "test test.txt", it doesn't work. I tried a bunch of things and one of them was to comment out the above code and echo the variables like this:
echo "fullpath = $fullpath<p>";
echo "size = ". filesize($fullpath);
print_r(stat($fullpath)); // I tried this when I saw filesize() was returning nothing
I noticed filesize() was returning nothing for the bad filename. stat() also returned nothing. But for normal filenames, both filesize() and stat() worked.
Any ideas?