-
-
Save ilhomelv/2094192957c6d3b1022fc4fec6db4718 to your computer and use it in GitHub Desktop.
Save Ajax POST data as a file with PHP
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 | |
//error_reporting(E_ALL); | |
//var_dump($_SERVER); | |
$post_data = $_POST['data']; | |
if (!empty($post_data)) { | |
$dir = 'YOUR-SERVER-DIRECTORY/files'; | |
$file = uniqid().getmypid(); | |
$filename = $dir.$file.'.txt'; | |
$handle = fopen($filename, "w"); | |
fwrite($handle, $post_data); | |
fclose($handle); | |
echo $file; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment