- in_array: documentation ( source)
- file_exists: documentation ( source)
<?php
// Move the temporary uploaded file to its final location,
// it should be available at the location "/tmp/boxed/success/agentSvcfRiuOSj5em1t.pdf".
$path = '/tmp/boxed/success/';
$mimes = [
'application/pdf',
'application/x-pdf'
];
$file = $_FILES['agentSvcfRiuOSj5em1t.pdf'];
$fileName = $file['name'];
if (file_exists($file['name'])) {
throw new \Exception('file does not exist');
}
if (in_array($mimes,$file['mime'])) {
throw new \Exception('mime type not allowed');
}
do_move($file['name'], $path.$fileName);
?>