Jump to content

mkdir(name, 0777); permissions ?


koolaid

Recommended Posts

Hi guys, i am having trouble with permissions after I make a directory.

It makes my directory then writes my .xml file to it exactly how i would like it to, but then when i ftp in i cannot delete that directory.

 

I am on a linux server.

Does anyone have any insight for me?

 

I am making a new directory and writing an xml file to it, like so

<?php
$var1 = $_POST["stringXML"];
$varrandom = $_POST["randomString"];
$folder = "./pending/$varrandom/";
if(!is_dir($folder)) mkdir($folder, 0777);

$mode = file_exists($folder.'pending.xml')?'a':'w';
$fp = fopen($folder.'pending.xml',$mode); 
fwrite($fp, "$var1");  
  

fwrite($fp, "\r\n\r\n");
fclose($fp);

?>

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/165357-mkdirname-0777-permissions/
Share on other sites

It's probably because Apache is running as root (or different group/user), so it creates the file that it only can manage. So you can't directly use ftp but still can manage it using your script, http://php.net/unlink or SSH to chown the file

 

Then again thats as far as I get, lets see if other users have a different way to manage this

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.