Folks,
I am building a membership script for 21 months now!!! That long!!!
Anyway, I need members to say infront of their cams a few things and then upload the vid file to the site (from the confirm_id.php page) where the member’s sponsor (recruiter) will get the video copy to check if it’s the real person with the real personal details or not. If true details, then sponsor verifies the member account. Else, unverifies it.
Now, I been testing my code. I uploaded an mp4 file. That should be ok but I get echoed:
“There was a problem uploading your video file $file_name! Make sure your file is an MP4 or a WAV file. You may try again now.”
Why ?
Not pasting the whole script as really long. Would do your head in.
Only pasting relevant part:
[code]
if($_SERVER[“REQUEST_METHOD”] == “POST”)
{
if(!isset($_FILES[“id_verification_video_file”])) //REtype
{
echo “no isset”;
}
else
{
$id_verification_video_file = $_FILES[‘id_verification_video_file’]; //REtype
//Feed Id Video Verification File Upload Directory Path.
$directory_path = “uploads/videos/id_verifications/”;
//Make Directory under $user in ‘uploads/videos/id_verifications’ Folder.
if(!is_dir(“$directory_path” . “$user”))
{
$mode = “0777”;
mkdir(“$directory_path” . “$user”, “$mode”, TRUE); //Thanks Requinix for my “$mode” typo hint.
}
//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’];
//Grab File Extension details.
$file_extension = pathinfo($file_name, PATHINFO_EXTENSION);
if(file_exists(‘$directory_path’ . ‘$user/’ . ‘$file_name’))
{
$Errors[] = “Error: You have already uploaded a video file to verify your ID!”;
exit();
}
else
{
//Feed allowed File Extension(s).
$allowed_file_extensions = array(“mp4” => “video/mp4″,”wmv” => “video/wmv”);
//Feed allowed file size.
$max_file_size_allowed_in_bytes = 1024*1024*100; //Allowed limit: 100MB.
$max_file_size_allowed_in_kilobytes = 1024*100;
$max_file_size_allowed_in_megabytes = 100;
$max_file_size_allowed = “$max_file_size_allowed_in_bytes”; //RETYPE
//Verify File Extension.
if(!array_key_exists($file_extension,$allowed_file_extensions)) die(“Error: Select a valid video file format. Select an MP4 or WAV file.”);
//Verify MIME Type of the file.
elseif(!in_array($file_type,$allowed_file_extensions))
{
echo “Error:<font size =’5′ font color =’red’><b>There was a problem uploading your video file $file_name! Make sure your file is an MP4 or a WAV file. You may try again now.</b></color></size>”; //THANKS TO REQUINIX FOR BRINNGING IT TO MY ATTENTION I AM STILL PROCESSING THE SCRIPT AFTER THIS LINE WHEN I SHOULD NOT.
exit();
}
//Verify File Size. Allowed Max Limit: 100MB.
elseif($file_size>$max_file_size_allowed) die(“Error: Your Video File Size is larger than the allowed limit of: $max_file_size_allowed_in_megabytes.”); //Fixed variable name typo. Thanks to Requinix & Simon JM.
//Move uploaded File to newly created directory on the server.
move_uploaded_file(“file_tmp”,”$directory_path” . “$user/” . “$file_name”);
//Notify user their File was uploaded successfully.
echo “<font size =’5′ font color =’red’><b>Your Video File “$file_name” has been uploaded successfully! You will get notified once your Id has been verified successfully.</b></color></size>”;
Can you spot my coding error ?
Any other errors ?
How-about you show me code sample how you’d do it better and simpler with as much less lines of codes as possible ? ?