I've seen that many people have problems with "Safe Mode On" settings in CMS Made Simple (CMSMS), when trying to upload one or more files to a newly created directory. The problem isn't trivial so the solution (that I came up with) is more a "work around" than a fix.
My case is as follows: "I have a client that has changed to a new hosting parter where it's not possible to disable the Safe Mode setting". Thus, when the user wants to upload new files they first create a new directory and then upload the file int this directory.
The problem is that the newly created directory has new permissions, typically with httpd rights rather than user right. Thus, it's only possible to create the directory but not to upload any files to the directory. The solution is to use ftp_mkdir in php instead. That way we can log in to the account and create the directory with user rights. Pretty simple if you think about it. In CMSMS you need to go to admin directory and open the file "imagefiles.php" and go to approx. line no. 123 (from v.1.2.3). Customize the following code such that it fits you own ftp account:
//mkdir($dir."/".$_POST['newdir'], 0777);
$server='ftp-server-address';
// ftp server $connection = ftp_connect($server);
// connection // login to ftp server $user = "ftp-username";
$pass = "ftp-pass";
$result = ftp_login($connection, $user, $pass);
$newDir = $dir.$_POST['newdir'];
$newDir = substr($newDir, 30);
//only for my server solution - might be diff. for you // check if connection was made
if ((!$connection) || (!$result)) { } else {
if(ftp_mkdir($connection,$newDir)) {
// create directory ftp_chmod($connection, 0777, $newDir);
} else { }
ftp_close($conn_id);
// close connection //exit();
}
audit(-1, $_POST['newdir'], 'Created Directory ddd');
NOTE: this solution worked with my hosting partner, surftown.dk. Let me know if you have another fix that might work. I hate this safe-mode problem......

Nice! Additional info: php5
Nice!
Additional info: php5 is required to get "ftp_chmod" to work.
Nice workaround! Have you
Nice workaround!
Have you delved any further into using this approach for other issues, such as module installation or theme installation? I've searched briefly through the site files, but my understanding of php isn't strong enough to reverse engineer these issues.
Any thoughts?
Hey guys. Thx for your
Hey guys.
Thx for your replies.
@Ed: no, I haven't delved further down to merging this approach with module / theme installs.
But it should be possible to use this approach as a general upload functionality in CMSMS.
If I get the time to develop such a module I'll post it both on this website and on cmsmadesimple.org
Cool, I'll poke around in the
Cool, I'll poke around in the code a bit as well, if I get a chance.
And glad I checked back; I just downloaded fontdoc, which you posted about after this post!
People should read this.
People should read this.
[...] Solution Use the ftp
[...] Solution Use the ftp functions in PHP to create the folders Se how at Henrik Hedegaard [...]
Works like a charm - you are
Works like a charm - you are the man !
Made a solution for the Typo3 install tool:
http://p2e.dk/noter/?p=217
Note for PHP4:
Use "ftp_site($connection,"CHMOD 0777 " . $newDir);" to set the permissions
Post new comment