OK, After much headbanging I figured out the first part of my problem. I want to retrieve a file from behind the webroot and to do this I need to send headers. This should be a simple case of finding out what the file is called (its extension) and sending the headers via a switch depending on what the extension is. My previous problem was that I had a URL string attached to the front of the filename which I got rid of in the variable $pfile
My question is how do I find out what the extension of my file is. I have tried explode but it doesn't have the desired effect. I feel stupid asking as I'm sure this is easy but I can't for the life of me figure it out: $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $pfile); // How do I say look at the extension and put it into the switch? $extension = $p; // end of the bit I'm stuck on. switch ($extension) { // define headers depending on $extension variable. case "doc" : header("Content-type: application/msword\n"); break; case "htm" : header("Content-type: text/html\n"); break; case "html" : header("Content-type: text/html\n"); break; case "jpg" : header("Content-type: image/jpeg\n"); break; case "pdf" : header("Content-type: application/pdf\n"); break; case "txt" : header("Content-type: text/plain\n"); break; case "xls" : header("Content-type: application/vnd.ms-excel\n"); break; default : // force download dialog if no extension defined. header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); break; } Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php