\n"; echo "_GET = \n"; print_r( $_GET ); echo "\n"; echo "_POST = \n"; print_r( $_POST ); echo "\n"; echo "_SERVER = \n"; print_r( $_SERVER ); echo "\n"; */ die('stop'); // GET or POST supported $op = $_GET['op']; if ( $op == null ) $op = $_POST['op']; $fn = $_GET['fn']; if ( $fn == null ) $fn = $_POST['fn']; $fn = 'samples/'.basename( $fn ); if ( $op == 'PUT' ) { // direct read, see: https://www.php.net/manual/en/wrappers.php.php#wrappers.php.input // for client, use POST with header: http.setRequestHeader( "Content-type", "application/octet-stream" ) // see: https://stackoverflow.com/questions/12348216/uploading-a-file-with-xmlhttprequest-missing-boundary-in-multipart-form-data $data = file_get_contents('php://input'); if ( strlen( $data ) == 0 ) { echo "error: zero length! file NOT saved\n"; } else { // file_put_contents( $fn, $data ); // echo "saved\n"; echo "saving to cloud on this website is currently OFF, \n"; } } else if ( $op == 'APPEND' ) { $data = file_get_contents('php://input'); // file_put_contents( $fn, $data, FILE_APPEND ); // echo "appended\n"; echo "saving to cloud on this website is currently OFF, \n"; } else if ( $op == 'GET' ) { // nb. bypasses HTTP server and any transformations $data = ''; if ( is_readable( $fn ) ) $data = file_get_contents( $fn ); echo $data; } return; /* */ ?>