Jump to content

Create a file which is chmod 777


MadnessRed

Recommended Posts

The touch() function sets the access and modification time of the specified file.

how does that help me?

 

 

how about this code though?

//First set the file path
$file = $_get['directory'].'/'.$_get['name'].'.txt';

//now the option to put in some content, blank atm
$content = "";

//Now we don't want to damage an existing files
if (file_exists($file)) {
   echo 'Error, file already exists';
}else{
   //Create the file
   file_put_contents($file,$content);
   //Make it writeable
   chmod($file,0777);
   //Success, lets tell them
   echo 'File made successfully';
}

yh but i use unix through gnome, not php

 

how about this code then?

 

//First set the file path
$file = $_get['directory'].'/'.$_get['name'].'.txt';

//now the option to put in some content, blank atm
$content = "";

//Now we don't want to damage an existing files
if (file_exists($file)) {
   echo 'Error, file already exists';
}else{
   //Create the file
   touch($file);
   //Make it writeable
   chmod($file,0777);
   //Add contents is I decide to make them
   file_put_contents($file,$content);
   //Success, lets tell them
   echo 'File made successfully';
}

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.