Created
February 1, 2015 23:15
-
-
Save toodooleedoo/e40428bd4a9f7128deb4 to your computer and use it in GitHub Desktop.
PHP File writer. Just drop in file then call eg writer.php?file=myfile&data=stuff in file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data=$_REQUEST['data']; | |
$file='files/'.$_REQUEST['file']; | |
$fh = fopen($file, 'a+') or die("can't open file"); | |
if (flock($fh, LOCK_EX)) { | |
if(!empty($file)) { | |
echo '**** Writing to file: '.$file.' '; | |
echo "\n"; | |
if(empty($data)) { $data=""; } | |
echo $data; | |
echo "\n"; | |
fwrite($fh, $data); | |
} else { | |
echo 'Improper parameters passed'; | |
} | |
echo "\n"; | |
fwrite($fh, "\n"); | |
flock($fh, LOCK_UN); | |
} | |
fclose($fh); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment