EDIT: a good point from salathe in the comments:
The first 8 characters of the uniqid() return value (minus any provided prefix) represent the Unix timestamp at the time of the function call. Using only the first 4 characters means that the value will only change every 2^16 seconds (~18 hours). For example, if this code were executed at any time between (and including) 2017-09-24T00:44:48Z and 2017-09-24T18:57:03Z it would return the same "unique" value.
You may will have collision issues with only four characters considering the first 4 values will only change around every 18 hours (assuming you are calling this script at least 2 two times within 18 hours).
Using the last four characters would be more 'unique'.
If you need to use the uniq
function you can use the substr function.
$unique = uniqid('', true);
$file_name = substr($unique, strlen($unique) - 4, strlen($unique));
$file_upload_name = $file_name . "." . $file_type;
Be aware having videos with only four characters lessens the uniqueness of video IDs and increases the collision rate of a generated file name being the same.