hobojjr Posted September 3, 2006 Share Posted September 3, 2006 Hi,I am trying to do the following1)new dir2)copy existing files to new dir3)upload some new files to the new dir3)do something to the new files4)delete copied filesAt the end I want to end up with the new dir so that people can read it only. Can somone help me out with the file/folder mod permission for each step? Quote Link to comment Share on other sites More sharing options...
tomfmason Posted September 3, 2006 Share Posted September 3, 2006 Well first I would like to say welcome to phpfreaks!Now lets see what I can do for you.1:)You can create a new directory with the [url=http://us3.php.net/manual/en/function.mkdir.php]mkdir[/url] function. Now depending one the OS you may need to set a chmod. If you are using Windows then you do not need to specfi a chmod. [b]For Windows[/b][code=php:0]mkdir("yourdir");[/code][b]For *nix[/b][code=php:0]mkdir("yourdir", 0700);[/code]You may want to study up on [url=http://catcode.com/teachmod/]chmod[/url] I normarly do something like this[code=php:0]$path = "path/to/dir";$chmod = '';//what ever chmod that you wantif (is_dir($path . "/yourdir") == false) {//checks to see if the new directory already exits mkdir("yourdir", $chomd);}[/code]2:) Now you can go about this in a couple different ways. This depends on if you are wanting to copy all of the files in one directory or if you are wanting to just copy a few files to the new diretory(.i.e.. index.php or html).If you are wanting to copy all files from a directory then you may want to look into [url=http://us3.php.net/manual/en/function.opendir.php]opendir[/url] and [url=http://us3.php.net/manual/en/function.readdir.php] readdir[/url]Now ether way you will want to look into [url=http://us3.php.net/manual/en/function.fopen.php]fopen[/url], [url=http://us3.php.net/manual/en/function.fread.php]fread[/url] and [url=http://us3.php.net/manual/en/function.fwrite.php]fwrite[/url].3:) You can check out this great tutorial for createing a [url=http://www.phpfreaks.com/tutorials/85/0.php]File Upload Class[/url]4:)To delete a file you can use [url=http://us3.php.net/manual/en/function.unlink.php]unlink[/url] and for directorys [url=http://us3.php.net/manual/en/function.rmdir.php]rmdir[/url]I hope this helps.Good Luck,Tom Quote Link to comment Share on other sites More sharing options...
hobojjr Posted September 3, 2006 Author Share Posted September 3, 2006 Thanks for the welcome and your reply.I know how to write my script but I am not getting the result I want.I need to know what permission to set for the folder and the scripts while going through the above mentioned stages. ;D Quote Link to comment Share on other sites More sharing options...
tomfmason Posted September 3, 2006 Share Posted September 3, 2006 I am going to assume that you are using a *nix system. Now you have to be careful. I am not sure if your host has set you as a owner or in a group or what. To be safe 0774 would allow read, write and execute access to the file/dir. Now I guess that you could play with this a bit. Also, what ftp program are you using. You can set the chmod via ftp and it might be a bit easier. Check out [url=http://us3.php.net/manual/en/function.chmod.php]chmod[/url].Good Luck,Tom Quote Link to comment Share on other sites More sharing options...
hobojjr Posted September 3, 2006 Author Share Posted September 3, 2006 I need to do it with php script.When I run my script I end up with a dir that I cannot delete it or the files inside.edit----the problem is, when I run the script and creat new dir and copy the files, I cannot delete the dir/files and I cannot change their mod from my ftp account.I am hosted by yurx.com ----general server info----Operating system LinuxService Status Click to ViewKernel version 2.6.9-22.ELsmpMachine Type i686Apache version 1.3.36 (Unix)PERL version 5.8.7Path to PERL /usr/bin/perlPath to sendmail /usr/sbin/sendmailInstalled Perl Modules Click to ViewPHP version 4.4.2MySQL version 4.1.21-standardcPanel Build 10.8.2-RELEASE 119Theme cPanel X v2.5.0Documentation Click to ViewcPanel Pro 1.0 (RC36) 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.