Uploading error named “Error creating folder” in Fckeditor
Last few days i was trying to solve a path issue regarding the Fckeditor. I was using the editor with php.It was little bit annoying this time cause it took few hours to find out. The editor was working fine wihtout any problem. For no reason suddenly the editor started showing the error messge while i was tyring to upload an image with the html editor. Most of the time the error seems more or less like below :
-
Error creating folder '/Resources/ImageFile/image' {Can't create 'image' directory}
-
Not getting the UserFilesAbsolutePath.
Well the editor have a configuration file for solving this issue with php.Here we need to be sure for the following three lines of code.
- $Config['UseFileType'] = true ;
- $Config['UserFilesPath'] = ‘/Resources/ImageFile/’ ;
- $Config['UserFilesAbsolutePath'] = ‘D:/PHPWorks/alpha-v2/Resources/ImageFile/’ ;
Remember the file path for UserFilesAbsolutePath usually not given while we download Fckeditor. In few versions of fckeditor it works fine without this path. But to stop the error message if any we should enter an absolute path for the destination directory. In my case my server was a windows server. Thats why i used the absolute path like above.
Last but not least imoprtant issue is the chmod of the destination directory should be set to 777 that means the directory should be writable to upload an image in it.
Tips while working with strings
Tips while working with strings
string concatenation
echo ‘php’, ‘developer’; // saves overhead time for string concatenation.
echo ‘foo’ . ‘bar’; // slower..
Interpolation
$variable = ‘this is ‘.$another_var.’ with me’; // faster
$variable = “this is $another_var with me”; // slower
Tip:
Simply use the single quote instead of double quote.
Avoid the string concatenation with (.) if possible.
Copy Method in PHP
Php copy method is like below:
bool copy ( string $source , string $dest [, resource $context ] )
It makes a copy of the file from source to dest.
Now in the following example we will see the codes where copy operation is done.
<?php
$dest = “/Folder1″ ;
$source = “/Folder2″;
copyr($source, $dest);
function copyr($source, $dest)
{
if (is_file($source))
{
$c = copy($source, $dest);
chmod($dest, 0777);
return $c;
}
// Make destination directory
if (!is_dir($dest))
{
$oldumask = umask(0);
mkdir($dest, 0777);
umask($oldumask);
}
// 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”)
{
echo “/$entry”;
copyr(“$source/$entry”,”$dest/$entry”);
}
}
// Clean up
$dir->close();
return true;
}
?>
Warning
If the destination file already exists, it will be overwritten.
Now all the files from the Folder1 should be copied in Folder2.
-
Archives
- September 2009 (1)
- August 2009 (2)
- July 2009 (3)
- June 2009 (2)
- May 2009 (3)
- April 2009 (2)
- March 2009 (11)
- February 2009 (6)
- August 2008 (1)
- May 2008 (2)
- March 2008 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS