<?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...';
}
}
?>