3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Simple file uplaod script. * NO WARRANTY. THIS SCRIPT IS ONLY AN EXAMPLE. * INPUT VALIDATION IS MINIMAL. DO NOT USE IN PRODUCTION * * @copyright 2014 Alex Soban * @license http://opensource.org/licenses/MIT * @author Alex Soban <me@soban.co> */ define('TOKEN', '<secure_token>'); define('UPLOADS', __DIR__ . '/uploads/'); define('URL', 'http://www.example.com/uploads/'); function output(array $data = array()) { header('Content-Type: application/json'); echo json_encode($data); exit; } // `t // get the filename and contents $filename = trim(preg_replace('/[^\d\w.]+/i', '', $_POST['name'])); $image = base64_decode($_POST['image']); // "upload" the file to our uploads directory if (!file_put_contents(UPLOADS . $filename, $image)) { output(array('error' => 'Failed saving file.')); } // return file public URL output(array('href' => URL . $filename));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "name" in /in/b41SU on line 26 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/b41SU on line 26 Warning: Undefined array key "image" in /in/b41SU on line 27 Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /in/b41SU on line 27 Warning: file_put_contents(/in/uploads/): Failed to open stream: Is a directory in /in/b41SU on line 30 Warning: Cannot modify header information - headers already sent by (output started at /in/b41SU:26) in /in/b41SU on line 17 {"error":"Failed saving file."}

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.19 ms | 403 KiB | 8 Q