I'm hoping one of you experts out there might be able to help me out with some issues I've been experiencing with my script. I'll try my best to explain what I have.
I've created a small PHP-based system for a client of mine. I built this system on my testing machine which is a Linux server with PHP 5.xx. My clients production machine is a Windows-based server, which also has the same version of PHP installed.
The system I built basically builds an order sheet based on information the user enters. The user can also attach files to the order. The order sheet is then saved to the server and is also emailed to the order desk and to the customer. My problem is that it doesn't always work on the Windows server but works 100% of the time on my testing machine. I've noticed several problems on the Windows server ... which I'll explain below. Yet what's odd is that it does work some of the time as well. Strange?!?
Initially a temporary folder is created for the user if the user adds files to their order. Later the contents of this folder is moved to a new folder, which is created by the script. My first question ... does it make a difference how I create and copy folders and content using PHP on the Windows server?
For example, I use the following to create folders:
Code: Select all
// cleanup post data
function cleanup($data) {
$data = ereg_replace("[^A-Za-z0-9 ]", "", $data);
return $data;
}
$strCustomerName = cleanup($_POST['strCustomerName']);
$strSavePath = "_savedOrders/Customers/" . $strCustomerName . "/";
if (!file_exists($strSavePath)) {
mkdir($strSavePath, 0777, true);
}
I use the following script to copy the contents of the temp folder to the new folder.
Code: Select all
function copyr($source, $dest) {
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== "$source/$entry") {
copyr("$source/$entry", "$dest/$entry");
}
}
// Clean up
$dir->close();
return true;
}
$strUploadPath = "_upload/" . $strSessionID . "/"; //$strSessionID is defined earlier in the script
copyr($strUploadPath, $strSavePath);
Again, this appears to work some of the time but not at other times. The biggest problem is that at times is appears that all of the contents found under the _upload folder get's copied to the root of the server drive ... which is very strange because I wouldn't' think that any script would have the permission to do something like that ... even if it did mess up. I'm wondering if this issue is being caused by issues with the create folder script above?
Hopefully this makes sense. I look forward to your responses.
Thanks