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......

Anonymous's picture

Nice! Additional info: php5

By Birger Eriksson (not verified) | 2008.02.25- 10:41

Nice!
Additional info: php5 is required to get "ftp_chmod" to work.

Anonymous's picture

Yes I too have experienced

By ToresMerd (not verified) | 2012.03.13- 09:36

Yes I too have experienced the same problem with your client. For that I avoid to change hosting or a domain, because the displacement process is very complicated and certainly inconvenient. erp software reviews

Anonymous's picture

convert m4v video

By thomasking (not verified) | 2012.04.19- 02:55

M4V Converter for Mac , Mac M4V Converter, Convert M4V Mac M4V to AVI Converter for Mac First Step, Just follow me to know more about M4V Converter: M4V to MP4 Converter for Mac The M4V Converter Mac is specially designed for Mac users to convert video M4V to FLV Converter for Mac files between all popula video and audio formats. M4V to WMV Converter for MacBesides, the powerful M4V Converter Mac software can let your enjoy your various videos on all sorts of playback M4V to MPEG Converter for Mac including PSP, iPod, Mobile Phone, Zune, iPhone, Apple TV and MP4/MP3 player. M4V to 3GP Converter for Mac Powerful Editing Function is provided such as Crop Video, M4V to MOV Converter for Mac Trim video or audio, Merge Video, adjust video effect, customize video output settings, M2TS to M4V Converter for Mac etc by the professional M4V Converter Mac OS X VOB to M4V Converter for Mac software. Tips: Support High-Definition and Standard Video ------ High-Definition video formats including AVCHD (MTS/M2TS), AVCHD Lite, HD MKV(H.264, MPEG-2 HD), HD WMV(VC-1), DAT to M4V Converter for Mac HD MOV(H.264, MPEG-4), HD TS, etc. M4V to PSP Converter for Mac and standard videos to WMV, MP4, FLV(Flash for posting online), M4V to iPod Converter for Mac AVI, MOV, MPG/MPEG, DV, etc. M4V Converter Mac convert M4V files to many popular video and audio files on Mac OS X with Mac M4V Converter! M4V to iPhone Converter for Mac

Anonymous's picture

This is an interesting site

By wandybrad (not verified) | 2012.05.05- 10:27

This is an interesting site and informative. I really impressed from this site.

professional business plan writers

Anonymous's picture

Nice workaround! Have you

By Ed (not verified) | 2008.02.28- 17:18

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?

Anonymous's picture

Hey guys. Thx for your

By Henrik Hedegaard (not verified) | 2008.02.28- 18:06

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

Anonymous's picture

I daily watch your website

By pardesh (not verified) | 2012.02.02- 23:34

I daily watch your website because it helps me in my many works and it is very beneficial for me because it gives the work a professional touch that is really an amazing thing. tow operator answering services

Anonymous's picture

Cool, I'll poke around in the

By Ed (not verified) | 2008.03.12- 04:51

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!

Anonymous's picture

It's really an outstanding

By steroe (not verified) | 2012.02.04- 12:19

It's really an outstanding and exciting to research. Never stop! This is one of the best blogs I have ever research. You have mad capabilities here. I just wish that you will not decrease your style because you are certainly one of the best web entrepreneurs. hcg canada group

Anonymous's picture

People should read this.

By Dea (not verified) | 2008.10.29- 04:30

People should read this.

Anonymous's picture

[...] Solution Use the ftp

By p2e.dk/noter » SAFE MODE / mkdir() solution (not verified) | 2008.12.24- 00:26

[...] Solution Use the ftp functions in PHP to create the folders Se how at Henrik Hedegaard [...]

Anonymous's picture

Works like a charm - you are

By Kasper (not verified) | 2008.12.24- 00:32

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

Anonymous's picture

Thanks

By Nanook (not verified) | 2011.01.16- 10:32

Thanks for the information. The solution is not difficult as usual. As for me, I often find answers to my question about CMSMS in different tutorials http://www.tubestime.com/watch/cms-made-simple-tutorial . I think they are very helpful.

Anonymous's picture

wow :)

By tv shows (not verified) | 2011.04.11- 21:25

Thanks for the information.
it looks great.

Anonymous's picture

I've searched briefly through

By barnet (not verified) | 2011.04.13- 19:02

I've searched briefly through the site files, but my understanding of php isn't strong enough to reverse engineer these issues.

Anonymous's picture

hi

By mirana (not verified) | 2011.05.04- 09:43

I just downloaded fontdoc, which you posted about after this post!

Torrents

Anonymous's picture

Very rarely, I came across a

By stagei (not verified) | 2012.01.26- 18:06

Very rarely, I came across a web page that is both useful and exciting, and I want to tell you that you have hit the take on the go. Your web page is important that this is something that not enough people to talk about properly. bend oregon vacation rentals

Anonymous's picture

Useful tutorial, clearly

By Emelie (not verified) | 2011.06.16- 21:16

Useful tutorial, clearly written and good reminder about the multiple levels of undo - always handy I find.

Anonymous's picture

I agree with you here. It is

By james lee (not verified) | 2011.11.14- 03:37

I agree with you here. It is definitely more of a work around them anything. This will work if you do it properly. Keep up the good work. Tutoring Manhattan

Anonymous's picture

Quite technical but then it

By barefoot beach naples florida (not verified) | 2011.11.30- 19:15

Quite technical but then it is good that you are providing such people who may seem stuck a way out. With this one will be able to know where to get help whenever they are trying to upload one or more files to a newly created directory.
barefoot beach naples florida

Anonymous's picture

This is actually satisfied

By claiser (not verified) | 2011.12.01- 11:35

This is actually satisfied through the great info is seen within this blog that to discussing the truly amazing info is seen within this blog. I'm really helpful info with this website and taking advantage of the truly amazing technology within this website.casino postepay

Anonymous's picture

Not that simple to do it

By Casinò Online (not verified) | 2012.01.10- 15:44

Is not simple, but for sure is going to increase the safety procedure of cms.

Especially when you have Casinò sites.

Thanks for sharing.

Anonymous's picture

Dive center websites are

By tropina (not verified) | 2012.01.21- 02:35

Dive center websites are increasing with the passage of time. I agree with your point and info you have provided here. I want more description about this topic in coming days. bodybuilding supplements

Anonymous's picture

Are you sure ?

By Anonymoussad (not verified) | 2012.01.25- 12:16

Are you sure ?

Anonymous's picture

Here is my comment to show my

By Johnny (not verified) | 2012.01.27- 20:02

Here is my comment to show my appreciation to this post. It is just that one I was looking for and I can say I have found it. John Harman have always tried to understand this but here it is my only solution.cheap printing can now be mentioned so I inviting all to accept this.

Anonymous's picture

Working in Safe Mode has

By Kumara (not verified) | 2012.01.31- 23:30

Working in Safe Mode has always bugged me, because I never knew how to upload my files. I thought about getting a registry cleaner from paretologic's website to clean everything up, but fortunately I found your solution instead. Using ftp_mkdir in php has never crossed my mind, but it seems like the right thing to do. Thanks!

Anonymous's picture

That's great. Thanks for

By Ovulation calculator (not verified) | 2012.02.01- 18:40

That's great. Thanks for discussing the solution.

Anonymous's picture

Nice post

By Anonymous (not verified) | 2012.03.06- 05:04

I really loved reading your blog. It was very well authored and easy to understand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting.London Paris New York Songs Download

Anonymous's picture

Re:Nice

By Anonymous (not verified) | 2012.03.06- 05:05

This blog post was absolutely fantastic. When I used to work in electroplating they sometimes encouraged us to write, but I could never come up with something as well written as that

Anonymous's picture

Re:Nice

By Anonymous (not verified) | 2012.03.06- 05:06

I found your site while stumbling. allowed me to really understand this issue. I really learned a lot from your site. You are doing good work!Sadda Adda Songs Download

Anonymous's picture

Good Post

By Anonymous (not verified) | 2012.03.06- 05:07

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.Players Movie songs Download

Anonymous's picture

Amazing Post

By Anonymous (not verified) | 2012.03.06- 05:08

I found this site very informative because very qualitative stuff is available over here.Thanks.
English Songs Download

Anonymous's picture

Wow nice post

By Anonymous (not verified) | 2012.03.06- 05:08

I wanted to thank you for this excellent read. its very fine post. thanks for sharing it.I found so many interesting stuff in your blog especially its discussion.Ek Deewana Tha Songs Download

Anonymous's picture

Nice post

By Anonymous (not verified) | 2012.03.06- 05:13

Its really a great post. I am sure that anyone would like to visit it again and again. After reading this post I got some very unique information which are really very helpful for anyone. This is a post having some crucial information. I wish that in future such posting should go on.London Paris New York Songs Download

Anonymous's picture

Re:Nice

By Anonymous (not verified) | 2012.03.06- 05:13

I have read many blogs and found good and informatics but this blog has simply thrill me with it designs, colour combination and the most important thing real information. I have found only genuine and useful information on this blog.Sadda Adda Songs Download

Anonymous's picture

great

By resub (not verified) | 2012.04.04- 11:13

I must say this is quite interesting Information. From a very long time i was searching for this type of blog.
I am looking forward to more such School Grantsposts in future. Thanks for sharing.

Anonymous's picture

inof

By eddy (not verified) | 2012.04.27- 09:38

interesting

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Insert Flickr images: [flickr-photo:id=230452326,size=s] or [flickr-photoset:id=72157594262419167,size=m].

More information about formatting options

Twitter - my latest burps

Around the web in 30 links

Last.FM - inside my ears