3v4l.org

run code in 300+ PHP versions simultaneously
<?php foreach ($_FILES as $file) { // array of valid extensions $validExtensions = array('.jpg', '.jpeg', '.gif', '.png'); // get extension of the uploaded file $fileExtension = strrchr($file['name'], "."); // check if file Extension is on the list of allowed ones if (in_array($fileExtension, $validExtensions)) { $newNamePrefix = time() . '_'; save('uploads/' . $newNamePrefix . $file['name']); echo 'Done ...'; } else { echo 'You must upload an image...'; } } ?>

preferences:
34.1 ms | 402 KiB | 5 Q