Jump to content


Photo

help with dir/file modes


  • Please log in to reply
4 replies to this topic

#1 hobojjr

hobojjr
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 03 September 2006 - 02:45 AM

Hi,

I am trying to do the following

1)new dir
2)copy existing files to new dir
3)upload some new files to the new dir
3)do something to the new files
4)delete copied files

At 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?

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 03 September 2006 - 03:30 AM

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

For Windows

mkdir("yourdir");


For *nix

mkdir("yourdir", 0700);
You may want to study up on chmod

I normarly do something like this
$path = "path/to/dir";
$chmod = '';//what ever chmod that you want
if (is_dir($path . "/yourdir") == false) {//checks to see if the new directory already exits
   mkdir("yourdir", $chomd);
}

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 opendir and readdir

Now ether way you will want to look into fopen, fread and fwrite.

3:) You can check out this great tutorial for createing a File Upload Class

4:)To delete a file you can use unlink and for directorys rmdir

I hope this helps.


Good Luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 hobojjr

hobojjr
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 03 September 2006 - 03:57 AM

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

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 03 September 2006 - 04:14 AM

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

Good Luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 hobojjr

hobojjr
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 03 September 2006 - 02:40 PM

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  Linux
Service Status Click to View
Kernel version 2.6.9-22.ELsmp
Machine Type i686
Apache version 1.3.36 (Unix)
PERL version 5.8.7
Path to PERL /usr/bin/perl
Path to sendmail /usr/sbin/sendmail
Installed Perl Modules Click to View
PHP version 4.4.2
MySQL version 4.1.21-standard
cPanel Build 10.8.2-RELEASE 119
Theme cPanel X v2.5.0
Documentation Click to View
cPanel Pro 1.0 (RC36)







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users