Folks,
I need your brilliant help to teach me how to use the finfo() function when it’s to do with uploading the right file with the right max size.
I only want to allow users to upload video file no more than 10MB in size.
Now, how to write the code with finfo() ?
This is my best shot …
[code]
<?php
//Grab Uploading File details.
$Errors = Array(); //SHOULD I KEEP THIS LINE OR NOT ?
$file_name = $_FILES[“id_verification_video_file”][“name”];
$file_tmp = $_FILES[“id_verification_video_file”][“tmp_name”];
$file_type = $_FILES[“id_verification_video_file”][“type”];
$file_size = $_FILES[“id_verification_video_file”][“size”];
$file_error = $_FILES[‘id_verification_video_file’][‘error’];
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo finfo_file($finfo, “$directory_path/$user/uploads/$file_name”);
finfo_close($finfo);
?>
<form METHOD=”POST” ACTION=”” enctype=”multipart/form-data”>
<fieldset>
<p align=”left”><h3><?php $site_name ?> ID Video Verification Form</h3></p>
<div class=”form-group”>
<p align=”left”<label>Video File: </label>
<input type=”file” name=”id_verification_video_file” id=”id_verification_video_file” value=”uploaded ‘Id Verification Video File.'”></p>
</div>
</fieldset>
<p align=”left”><button type=”submit” class=”btn btn-default” name=”id_verification_video_file_submit”>Submit!</button></p>
</form>
</body>
</html>
Now, I need your expertise to fill-in the rest of the missing puzzle pieces so I can learn from your sample code.
Yeah, I know I should be writing conditions where script shows error if right file type not given or file size exceeds limit. But, I know not how to start with this finfo() function. The manual was no good. Hence, I need you guys to chime in and shove your wands right this way and add your bits of pieces to help me solve the puzzle! ?
Do hop on-board!