Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 10th, 2007, 9:42 PM   #1
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 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
Old Jan 11th, 2007, 12:41 AM   #2
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
To change a file's permission in php use the chmod() function. Read more on it here
http://us2.php.net/manual/en/function.chmod.php
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Jan 11th, 2007, 10:50 AM   #3
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Thanks grimpirate, now I feel like an idiot. I looked at the file ref page and totally skipped it. Sorry I'm an Idiot, but once again, Thank You
PhilBon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Permission error Samuaijack ASP.NET 4 Nov 1st, 2006 5:21 PM
Changing The <title> Tags Sane JavaScript and Client-Side Browser Scripting 2 Jul 16th, 2006 11:44 AM
changing permissions in windows XP using ruby!! kraf001 Other Programming Languages 0 Sep 27th, 2005 1:58 AM
ADSI Changing Password - Access Denied bobfox Visual Basic .NET 1 Sep 22nd, 2005 1:22 PM
Permission denied soren HTML / XHTML / CSS 1 Jan 18th, 2005 6:42 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC