Mistat2000 Posted August 6, 2007 Share Posted August 6, 2007 Hi Folks, I recently downloaded a document management system and am having a file upload problem. When I try and upload the file I get the following error: Adding document "App Shortlist" to folder "Forms"... Warning: mkdir() failed (File exists) in c:\phpdev\www\public\databases\mydms\inc\inc.FileUtils.php on line 48 An error has occured What it seems to be doing is the first time I upload a document it works ok, then when I try and add another document to the same directory is comes up with the error above.. here is the code in the FileUtils.php include: <?php // MyDMS. Document Management System // Copyright (C) 2002-2005 Markus Westphal // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. function renameFile($old, $new) { return rename($old, $new); } function removeFile($file) { return unlink($file); } function copyFile($source, $target) { return copy($source, $target); } function moveFile($source, $target) { if (!copyFile($source, $target)) return false; return removeFile($source); } function renameDir($old, $new) { return rename($old, $new); } function makeDir($path) { return mkdir($path, 0755); } function removeDir($path) { $handle = opendir($path); while ($entry = readdir($handle) ) { if ($entry == ".." || $entry == ".") continue; else if (is_dir($path . $entry)) { if (!removeDir($path . $entry . "/")) return false; } else { if (!unlink($path . $entry)) return false; } } closedir($handle); return rmdir($path); } function copyDir($sourcePath, $targetPath) { if (mkdir($targetPath, 0777)) { $handle = opendir($sourcePath); while ($entry = readdir($handle) ) { if ($entry == ".." || $entry == ".") continue; else if (is_dir($sourcePath . $entry)) { if (!copyDir($sourcePath . $entry . "/", $targetPath . $entry . "/")) return false; } else { if (!copy($sourcePath . $entry, $targetPath . $entry)) return false; } } closedir($handle); } else return false; return true; } function moveDir($sourcePath, $targetPath) { if (!copyDir($sourcePath, $targetPath)) return false; return removeDir($sourcePath); } //To-DO: fehler abfangen function getSuitableDocumentDir() { GLOBAL $settings; $maxVal = 0; $handle = opendir($settings->_contentDir); while ($entry = readdir($handle)) { if ($entry == ".." || $entry == ".") continue; else if (is_dir($settings->_contentDir . $entry)) { $num = intval($entry); if ($num >= $maxVal) $maxVal = $num+1; } } $name = "" . $maxVal . ""; while (strlen($name) < 5) $name = "0" . $name; return $name . "/"; } ?> Any ideas as to why this is happening? Could it be permissions? Any help would be much appreciated! Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 6, 2007 Share Posted August 6, 2007 have a look at umask()... before creating files/dirs you should set it to 0 and then set it back to original once you have done. I suspect that thepermissions are incoorect because of this. Quote Link to comment Share on other sites More sharing options...
Mistat2000 Posted August 6, 2007 Author Share Posted August 6, 2007 have a look at umask()... before creating files/dirs you should set it to 0 and then set it back to original once you have done. I suspect that thepermissions are incoorect because of this. Have managed to fix it I have a settings include and had a typo in the directory name once I set it properly I am now able to upload multiple docs into the same directory aaah the joys of a monday morning, i feel like its going to be one of those weeks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.