Jump to content

File Upload Problem


Mistat2000

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/63522-file-upload-problem/
Share on other sites

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  :o once I set it properly I am now able to upload multiple docs into the same directory  :D

 

aaah the joys of a monday morning, i feel like its going to be one of those weeks  :D

Link to comment
https://forums.phpfreaks.com/topic/63522-file-upload-problem/#findComment-316584
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.