3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Upload has a limit of 10 mb * @param string $dir $_SERVER['DOCUMENT_ROOT'] * @param string $path Path do you want to upload the file * @param string $filetype jpg|jpeg|gif|png|doc|docx|txt|rtf|pdf|xls|xlsx|ppt|pptx * @param array $_FILES An associative array of items uploaded to the current script via the HTTP POST method. * @return string ?$fileName:False */ function uploadFiles($dir, $path, $filetype, $_FILES) { $dir_base = "{$dir}{$path}"; $dateadded = date('ynj_Gis-'); $rEFileTypes = "/^\.($filetype){1}$/i"; $MAXIMUM_FILESIZE = 10 * 1024 * 1024; // UPLOAD IMAGES $isFile = is_uploaded_file($_FILES['file']['tmp_name']); if ($isFile) { $safe_filename = $dateadded . preg_replace(array('/\s+/', '/[^-\.\w]+/'), array('_', ''), trim($_FILES['file']['name'])); if ($_FILES['file']['size'] <= $MAXIMUM_FILESIZE && preg_match($rEFileTypes, strrchr($safe_filename, '.'))) { $isMove = move_uploaded_file($_FILES['file']['tmp_name'], $dir_base . $safe_filename); } } if ($isMove) { return $safe_filename; } else { return false; } }
Output for 5.4.20
Fatal error: Cannot re-assign auto-global variable _FILES in /in/Sl2Fm on line 10
Process exited with code 255.
Output for 5.4.0 - 5.4.19
Fatal error: Cannot re-assign auto-global variable _FILES in /in/feW5G on line 10
Process exited with code 255.
Output for 5.3.0 - 5.3.29

preferences:
177.36 ms | 1395 KiB | 58 Q