Skip to content

Instantly share code, notes, and snippets.

@ericjames
Created November 1, 2017 17:05
Show Gist options
  • Save ericjames/dbf4feb0d65a5f4caef37c5eb2bb4c60 to your computer and use it in GitHub Desktop.
Save ericjames/dbf4feb0d65a5f4caef37c5eb2bb4c60 to your computer and use it in GitHub Desktop.
Writing a file on a server via URL POST
<?php
error_reporting(-1);
header('Access-Control-Allow-Origin: *');
$store = isset($_POST['store']) ? substr($_POST['store'],0,10) : false;
$fp = fopen('test.txt', 'r+');
if ($store) {
fwrite($fp, $store);
}
$contents = fread($fp, 10000);
fclose($fp);
echo $contents;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment