Add wrapper around move_uploaded_file
This commit is contained in:
@ -317,4 +317,25 @@ final class MD_STD_IN {
|
||||
return $input;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around move_uploaded_file that throws errors in case the upload failed
|
||||
* for an identifiable reason.
|
||||
*
|
||||
* @param string $filename Name of the file to upload.
|
||||
* @param string $destination Destination to move the file to.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function move_uploaded_file(string $filename, string $destination):bool {
|
||||
|
||||
MD_STD::check_is_writable(dirname($destination));
|
||||
|
||||
if (!(\move_uploaded_file($filename, $destination))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user