View Single Post
Old Jan 10th, 2007, 10:42 PM   #1
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 4 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Changing File/Folder Permission

Hello Everyone, I was wondering if anyone knew how to change the file or Folder Permission in PHP. I have one script that for some weird reason has to have the destination Folder be set so that everyone can write to this, this is not ideal for a web file. I'm trying to make a folder with the date (where I'm getting stopped because permissions is denied. And then as you can see I want to put 3 files in there. I know it works if I change the folder to 777 but I don't want it to be. I was thinking about way could be ftp with php but that to me will take to much time to set up though I've done it before. This is also running on a mac server. Here is the code I'm working with if you want to see (not really important):
[php]
$location = "/home/username/public_html/files/";
if (file_exists($location . $month . "-" . $day . "-" . $year)){
echo "Date Already Present. If you would like to write over this, delete the previous one and then add the new one";
} else {
mkdir($location . $month . "-" . $day . "-" . $year . "/",0755);
if ($wmaupload == "1"){
//copy temp file to the folder
if (is_uploaded_file($_FILES['wma']['tmp_name'])){
move_uploaded_file($_FILES['wma']['tmp_name'],$location . $month . "-" . $day . "-" . $year . "/" . $_FILES['wma']['name']) or $wmaerror = true;
if ($wmaerror){
$error .= "The Windows Media File could not be Copied";
}
} else {
$error .= "The Windows Media File could not be uploaded";
$wmaerror = true;
}/**/
echo "wma = 1";
}
if ($mp3upload == "1"){
//copy temp file to the folder
if (is_uploaded_file($_FILES['mp3']['tmp_name'])){
move_uploaded_file($_FILES['mp3']['tmp_name'],$location . $month . "-" . $day . "-" . $year . "/" . $_FILES['mp3']['name']) or $mp3error = true;
if ($mp3error){
$error .= "The MP3 File could not be Copied";
}
} else {
$error .= "The MP3 File could not be uploaded";
$mp3error = true;
}/**/
echo "mp3 = 1";
}
if ($pdfupload == "1"){
//copy temp file to folder
if (is_uploaded_file($_FILES['pdf']['tmp_name'])){
move_uploaded_file($_FILES['pdf']['tmp_name'],$location . $month . "-" . $day . "-" . $year . "/" . $_FILES['pdf']['name']) or $pdferror = true;
if ($pdferror){
$error .= "The PDF File could not be Copied";
}
} else {
$error .= "The PDF File could not be uploaded";
$pdferror = true;
}/**/
echo "pdf = 1";
}
}
[/php]
PhilBon is offline   Reply With Quote