icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Permission denied error.

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 1st, 2004, 8:10 PM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Oct 2004
28 posts
Gave thanks: 0
Thanked 0 times
Permission denied error.

I need help getting this script to work, currently it's giving a permission denied error on line ten. There are other errors but this one needs to be fixed first. Does anyone know why it's not working?

Quote:
Warning: mkdir(./mscstff/): Permission denied in /home/website/public_html/tstm/zipzip.php on line 10
PHP Code:
<?php
$root_path 
"./"//for establishing root in a variable
$zipfrom $root_path 'miscstuff/'//directory getting files from
$ziptodir $root_path 'mscstff/'//directory for storing files to
$ziptofile =  "mscstff"//name of file to store to


function zipzip($zipfrom$ziptodir$ziptofile//zips files from a directory into another
{
  
mkdir($ziptodir0774); //creates directory for saving files to
  
$ziptofile_handle fopen($ziptodir $ziptofile '.gz',"a"); //creates saving to file
  
fclose($ziptofile_handle);
  
$dir_handle dir('$zipfrom'); //create handle for directory

  
while(false !== ($filefrom readdir($dir_handle))) //read first file from directory
  
{
    
//creates two handles for zipping to and reading
    
$gzfile_handle gzopen($ziptodir $ziptofile '.gz'"a9"); //hande for gz file, write+zp9
    
$filefrom_handle fopen($zipfrom $filefrom,"r"); //handle for filefrom

    //zips filefrom to ziptofile
    
$filefrom_size filesize($filefrom_handle); //reads filefrom size
    
$filefrom_chunk fread($filefrom_handle$filefrom_size); //reads from file
    
gzwrite($gzfile_handle$filefrom_chunk); //zips files content to gz

    //closing file handles for ziptofile and filefrom
    
gzclose($gzfile_handle);
    
fclose($filefrom_handle);

    
//test current success rate
    
$ziptodir_handle dir('$ziptodir'); //create handle for zipto directory
    
while(false !== ($currentprintout readdir($ziptodir_handle)))
    {
    echo 
"new-dir current content <BR>";
    echo 
$currentprintout;
    }
  }

closedir($dir_handle);
}

zipzip($zipfrom$ziptodir$ziptofile//zipzip function use

?>
cassius is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 1st, 2004, 8:17 PM   #2 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
Try changing this line:
mkdir($ziptodir, 0774);
to:
mkdir($ziptodir, 0777);
and see if it works.
__________________
Pass14
www.tqwebservices.com
www.autoappraisalsunlimited.com
www.clevelandlayne.com
Pass18
www.estateagency.com.au

Some people drink deeply from the fountain of knowledge. Others just gargle.
pbflash is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 1st, 2004, 8:40 PM   #3 (permalink)
Surpass Fan
Super #1
 
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
No, you need to chmod() the HOST directory to 0777, mkdir(), then chmod() back.

PHP Code:
chmod("/home/username/public_html/main_dir"0777);
mkdir("/home/username/public_html/main_dir/new_dir"0755);
chmod("/home/username/public_html/main_dir"0755); 
However, this is also presents a problem: as a result of certain safety features being enabled, you can not chmod() a directory or file that was not created by PHP. So, you get into a chicken-and-egg dilemma...
__________________
- Evan Charlton | [site] | Server - SH58
Kickersny.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 1st, 2004, 9:05 PM   #4 (permalink)
Registered User
Fresh Surpasser
 
Joined in Oct 2004
28 posts
Gave thanks: 0
Thanked 0 times
Thank you, I'll try that.
cassius is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On