I've built a PHP MySQL intranet site which handles a customer database, service tickets, ie. All works well. It was suggested recently that I add to it a place to attach files to individual customer accounts (spreadsheets, word documents, etc.). That all works fine as well. People can choose a customer account, created an attachment folder, upload files to that attachment folder, view the attached files when the customer information is accessed, and click on them to download them. Here is where my problem starts.
So far, files which have extensions greater than three characters (.xxx) will not download. Any file that has a .xxxx extension (4 or more characters) generates a 404 Page Cannot be Found error. The link to the file is dead on, no errors, but when it is clicked - 404 error. This happens across browsers, so I've eliminated browser incompatibility. I believe the problem has to be in the code that reads the document folder and generates the file list, but I cannot figure out where it is. Here is the code for viewing the folder contents:
<?php
$cf = $row['custcode'];
$sub = ($_GET['dir']);
$path = "../../pages/customers/custfolders/".$cf;
$path = $path . "$sub";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
if (substr($file, -4, -3) =="."){ echo "<li><a href='$path/$file'>$file</a></li>"; }
else{ echo "<li><a href='$path/$file'>$file</a></li>"; }
$i++;
}
}
closedir($dh);
?>
I though it might be worth mentioning that this only happens with Microsoft 2007 documents (Excel extension is .xlsx) so far. I tried .jpeg and it worked fine. It is important that all versions of Office documents be compatible with this.
Thanks in advance.