The files are images or xmls that the system uses to show content.
I need to use php because the system needs to test that the user is logged in to return those files (they will be put in an htaccess, .htpasswrd protected folder).
I am doing this using readfile. In my local server I have no problems but when I upload it to the company server and I stress test it (requesting files rapidly and/or from different clients) the server starts returning the same file instead of the different files that are being requested. Example client one ask for files 1,2,3,4,5 and client two asks for files 6,7,8 and client one ends up receiving files 1,2,3,2,2.
The server is a shared server so I can not install mod_xsendfile.
Is there any possible solution with php?
Here is the code:
Expand|Select|Wrap|Line Numbers
- $ext = pathinfo($url, PATHINFO_EXTENSION);
- if(file_exists($url)){
- switch (strtolower($ext)){
- case "swf":
- header("Content-type: application/x-shockwave-flash");
- break;
- case "jpg":
- case "jpeg":
- header('Content-Type: image/jpeg');
- break;
- case "gif":
- header('Content-Type: image/gif');
- break;
- case "png":
- header('Content-Type: image/png');
- break;
- case "flv":
- header("Content-Type: video/x-flv");
- break;
- case "xml":
- header('Content-Type: text/xml');
- break;
- case "css":
- header("Content-type: text/css");
- break;
- default:
- echo("Error");
- die();
- }
- header("Content-Length: " . filesize($url));
- readfile($url);
- die();