/    Sign up×
Community /Pin to ProfileBookmark

Is My File Upload Script Secure ? And Max What File Sizes Should I Allow ?

Folks,

I want to accept File Uploads on my website where users will uploads on my website. Which php functions I should use to detect that users are not uploading malicious files such as viruses, malwares, etc. ?

Top Question:
Is finfo_file() necessary to use here if I am using mime_content_type() and pathinfo() functions ?

Q1. What is your suggestion in terms of video file size that I should allow max for:

1 min vid
3 min vid
5 mins vid
10 mins vid
20 mins vid
30 mins vid

Video File types I am allowing are:

$video_mime_type = array(‘video/mp4′,’video/wav’,’video/ogg’,’video/flv’,’video/wmv’,’video/avi’);

Q2. What is your suggestion in terms of audio file size that I should allow max for:

1 min audio
3 min audio
5 mins audio
10 mins audio
20 mins audio
30 mins audio

Audio File types I am allowing are:
$audio_mime_type = array(‘audio/mpeg3’, ‘audio/x-mpeg-3′,’audio/mpeg’,’audio/wav’,’application/octet-stream’);

Q3. What is your suggestion in terms of text file size that I should allow max for:

1 page
5 page
10 page
50 page
100 page

Text File types I am allowing are:

$text_mime_type = array(‘application/pdf’,’text/plain’,’application/msword’,’application/vnd.openxmlformats-officedocument.wordprocessingml.document’);

Q4. What is your suggestion in terms of img file size (passport size) that I should allow max for 1 img ?

Img File types I am allowing are:

$img_mime_type = array(‘image/png’,’image/gif’,’image/jpeg’,’image/jpg’);

Q5. Is there anything else I should look into in terms of security before accepting uploads from my website visitors ?
I just want to make sure I won’t have problems where users upload malware, viruses, etc. that cause your server problem and my website. Since you have experience in these sort of things then I thought best ask.
First time I am running a vps and a website like this where I will accept user uploads. Hence, the nervousness and worries.

What measurements should have in-place on my rented vps (centOS 7) so if any user tries uploading dodgey files then it will be taken care of in the backend ? Suggest any virus, malware, etc. shields to be set in place on the vps ?

My php script will be checking for file types with mime_content_type(), and pathinfo() php functions.
If all seems well then I may stop worrying and start using my php script.

Q6. Anything else I should know ?

Thanks

Here is the File Upload Script. See if you can have a quick glance if you ain’t got too much time in your hands.

[code]
<?php
//include ‘header_account.php’;
//ERROR REPORTING CODES.
//declare(strict_types=1);
ini_set(‘display_errors’, ‘0’);
ini_set(‘display_startup_errors’, ‘0’);
error_reporting(0);
//mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$conn = mysqli_connect(“localhost”,”root”,””,”followingbrowser”);
if (!$conn)
{
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
print “$errno: $errorn”;
exit();
}

$error_msg = array();

$text_allowed_ext = array(‘pdf’,’txt’,’doc’,’docx’);
$video_allowed_ext = array(‘mp4′,’wav’,’ogg’,’flv’,’wmv’,’avi’);
$img_allowed_ext = array(‘jpeg’,’jpg’,’png’,’gif’);
$audio_allowed_ext = array(‘mp3′,’wav’);
$img_mime_type = array(‘image/png’,’image/gif’,’image/jpeg’,’image/jpg’);
$text_mime_type = array(‘application/pdf’,’text/plain’,’application/msword’,’application/vnd.openxmlformats-officedocument.wordprocessingml.document’);
$video_mime_type = array(‘video/mp4′,’video/wav’,’video/ogg’,’video/flv’,’video/wmv’,’video/avi’);
$audio_mime_type = array(‘audio/mpeg3’, ‘audio/x-mpeg-3′,’audio/mpeg’,’audio/wav’,’application/octet-stream’);

if($_SERVER[“REQUEST_METHOD”] == “POST”){

$error = 0 ;
$captcha=$_POST[‘g-recaptcha-response’];
$secretKey = “6Le-eXUUAAAAAAQSLdBJo0GGDrUil11Q7E28VCVb”;
$ip = $_SERVER[‘REMOTE_ADDR’];
// post request to server
$url = ‘https://www.google.com/recaptcha/api/siteverify?secret=’ . urlencode($secretKey) . ‘&response=’ . urlencode($captcha);
$response = file_get_contents($url);
$responseKeys = json_decode($response,true);

//var_dump($_Files); //For debugging.
//Check whether the file was uploaded or not without any errors.
if(!isset($_FILES[“id_verification_video_file”]) || !isset($_FILES[‘id_verification_txt_file’]) || !isset($_FILES[‘id_verification_audio_file’]) || !isset($_FILES[‘id_verification_img_file’])){
$error_msg[‘all’] = ‘<p class=”text-danger”>Please select all fields</p>’;
$error = 1;

} else if(!isset($_POST[‘g-recaptcha-response’])){
$error_msg[‘all’] = ‘<p class=”text-danger”>Please check the Captcha</p>’;
$error = 1;
}else if($responseKeys[“error”]){
$error_msg[‘all’] = ‘<p class=”text-danger”>Captcha Invalid</p>’;
$error = 1;
}else{
$txt_file = $_FILES[“id_verification_txt_file”][“name”];
$video_file = $_FILES[“id_verification_video_file”][“name”];
$audio_file = $_FILES[“id_verification_audio_file”][“name”];
$img_file = $_FILES[“id_verification_img_file”][“name”];

//filtes to check the file type extensions

if(!in_array(pathinfo($txt_file, PATHINFO_EXTENSION),$text_allowed_ext)){
$error_msg[‘txt_error’]= ‘<p class=”text-danger”>Invalid Extensions.Only PDF,text and DOC Files are allowed’;
$error = 1;
}

if(!in_array(pathinfo($video_file, PATHINFO_EXTENSION),$video_allowed_ext)){
$error_msg[‘video_error’] = ‘<p class=”text-danger”>Invalid Extensions. Only MP4, WAV, OGG, FLV, WMV and AVI Files are allowed’;
$error = 1;
}

if(!in_array(pathinfo($audio_file, PATHINFO_EXTENSION),$audio_allowed_ext)){
$error_msg[‘audio_error’]= ‘<p class=”text-danger”>Invalid Extensions. Only MP3 and WAV Files are allowed’;
$error = 1;
}

if(!in_array(pathinfo($img_file, PATHINFO_EXTENSION),$img_allowed_ext)){
$error_msg[‘img_error’]= ‘<p class=”text-danger”>Invalid Extensions. Only JPG, JPEG, PNG and GIFF Files are allowed’;
$error = 1;
}

//Checking mime type
if(!in_array(mime_content_type($_FILES[“id_verification_img_file”][“tmp_name”]),$img_mime_type)){
$error_msg[‘img_error’]= ‘<p class=”text-danger”>Invalid Extensions. Only Only JPG, JPEG, PNG and GIFF Files are allowed’;
$error = 1;
}

if(!in_array(mime_content_type($_FILES[“id_verification_txt_file”][“tmp_name”]),$text_mime_type)){
$error_msg[‘txt_error’]= ‘<p class=”text-danger”>Invalid Extensions. Only PDF, text and DOC Files are allowed’;
$error = 1;
}

if(!in_array(mime_content_type($_FILES[“id_verification_video_file”][“tmp_name”]),$video_mime_type)){
$error_msg[‘video_error’] = ‘<p class=”text-danger”>Invalid Extensions. Only MP4, WAV, OGG, FLV, WMV and AVI Files are allowed’;
$error = 1;
}
if(!in_array(mime_content_type($_FILES[“id_verification_audio_file”][“tmp_name”]),$audio_mime_type)){
$error_msg[‘video_error’] = ‘<p class=”text-danger”>Invalid Extensions. Only MP3 and WAV Files are allowed’;
$error = 1;

echo mime_content_type($_FILES[“id_verification_audio_file”][‘tmp_name’]);
}

//checking File Size using filesize function.

if(filesize($_FILES[‘id_verification_txt_file’]) > 100000000){
$error_msg[‘txt_file_size_err’] = ‘<p class=”text-danger”>File Size is greater than 100MB. File Size should not exceed the 100MB limit!’;
$error = 1;
}

if(filesize($_FILES[‘id_verification_video_file’]) > 100000000){
$error_msg[‘video_file_size_err’] = ‘<p class=”text-danger”>File Size is greater than 100MB. File Size should not exceed the 100MB limit!’;
$error = 1;
}

if(filesize($_FILES[‘id_verification_audio_file’]) > 100000000){
$error_msg[‘audio_file_size_err’] = ‘<p class=”text-danger”>File Size is greater than 100MB. File Size should not exceed the 100MB limit!’;
$error = 1;
}

if(filesize($_FILES[‘id_verification_txt_file’]) > 100000000){
$error_msg[‘img_file_size_err’] = ‘<p class=”text-danger”>File Size is greater than 100MB. File Size should not exceed the 100MB limit!’;
$error = 1;
}

//Checking if there are NO errors.

if($error == 0){
$user = $user; //Username here.
$db_user = ‘followingbrowser_user’; //Has to be in quotes.
//Feed Id Verification Video File Upload Directory path.
$directory_path = ‘uploads/id_verifications/’;
//make Directory under $user in ‘uploads/videos/id_verifications’ Folder.
$directory_path_and_user_dir = $directory_path.$user;
if(!is_dir($directory_path_and_user_dir)){

$db_user = ‘followingbrowser_user’; //Has to be in quotes.
$mode = 0755;
mkdir($directory_path_and_user_dir,$mode, TRUE); //This line is working and is correct even without quoting “$mode”. Requinix sugegsted to quote “$mode”.
}

//Making directories of every files for respective user.
$video_directory = $directory_path_and_user_dir.’/videos’;
$audio_directory = $directory_path_and_user_dir.’/audios’;
$text_directory = $directory_path_and_user_dir.’/text’;
$img_directory = $directory_path_and_user_dir.’/imgs’;

if(!is_dir($video_directory)){
$db_user = ‘followingbrowser_user’; //Has to be in quotes.
$mode = 0755;
mkdir($video_directory,$mode, TRUE); //This line is correct and working even without quoting $mode.
}

if(!is_dir($audio_directory)){
$db_user = ‘followingbrowser_user’; //Has to be in quotes.
$mode = 0755;
mkdir($audio_directory,$mode, TRUE); //This line is correct and working even without quoting $mode.
}

if(!is_dir($text_directory)){
$db_user = ‘followingbrowser_user’; //Has to be in quotes.
$mode = 0755;
mkdir($text_directory,$mode, TRUE); //This line is correct and working even without quoting $mode.
}

if(!is_dir($img_directory)){
$db_user = ‘followingbrowser_user’; //Has to be in quotes.
$mode = 0755;
mkdir($img_directory,$mode, TRUE); //This line is correct and working even without quoting $mode.
}

//Uploading the Video Files

$upload_file_err = 0;

//video Files
$video_file_name = $_FILES[“id_verification_video_file”][“name”];
$video_file_tmp = $_FILES[“id_verification_video_file”][“tmp_name”];
$video_file_type = $_FILES[“id_verification_video_file”][“type”];
$video_file_size = $_FILES[“id_verification_video_file”][“size”];
$video_file_error = $_FILES[‘id_verification_video_file’][‘error’];

$video_file_ext = pathinfo($video_file, PATHINFO_EXTENSION);

//audio files
$audio_file_name = $_FILES[“id_verification_audio_file”][“name”];
$audio_file_tmp = $_FILES[“id_verification_audio_file”][“tmp_name”];
$audio_file_type = $_FILES[“id_verification_audio_file”][“type”];
$audio_file_size = $_FILES[“id_verification_audio_file”][“size”];
$audio_file_error = $_FILES[‘id_verification_audio_file’][‘error’];

$audio_file_ext = pathinfo($audio_file, PATHINFO_EXTENSION);

//image files
$img_file_name = $_FILES[“id_verification_img_file”][“name”];
$img_file_tmp = $_FILES[“id_verification_img_file”][“tmp_name”];
$img_file_type = $_FILES[“id_verification_img_file”][“type”];
$img_file_size = $_FILES[“id_verification_img_file”][“size”];
$img_file_error = $_FILES[‘id_verification_img_file’][‘error’];

$img_file_ext = pathinfo($img_file, PATHINFO_EXTENSION);

//text files
$txt_file_name = $_FILES[“id_verification_txt_file”][“name”];
$txt_file_tmp = $_FILES[“id_verification_txt_file”][“tmp_name”];
$txt_file_type = $_FILES[“id_verification_txt_file”][“type”];
$txt_file_size = $_FILES[“id_verification_txt_file”][“size”];
$txt_file_error = $_FILES[‘id_verification_txt_file’][‘error’];

$txt_file_ext = pathinfo($txt_file, PATHINFO_EXTENSION);

$video_user_file_dir = $video_directory.’/’.$video_file_name;
$audio_user_file_dir = $audio_directory.’/’.$audio_file_name;
$img_user_file_dir = $img_directory.’/’.$img_file_name;
$txt_user_file_dir = $text_directory.’/’.$txt_file_name;

//$audio_user_file_dir = $audio_directory.’/’.$file_name;

$upload_err = 0;

//Uploading Video file
if(file_exists($video_user_file_dir)){
$error_msg[‘upload_video_error’] = ‘<p class=”text-danger”>You have already uploaded a video file to verify your ID! No need to upload and verify again!</p>’;
$upload_err = 1;
}

if(file_exists($audio_user_file_dir)){
$error_msg[‘upload_audio_error’] = ‘<p class=”text-danger”>You have already uploaded a Audio file to verify your ID! No need to upload and verify again!</p>’;
$upload_err = 1;
}

if(file_exists($img_user_file_dir)){
$error_msg[‘upload_img_error’] = ‘<p class=”text-danger”>You have already uploaded a Image file to verify your ID! No need to upload and verify again!</p>’;
$upload_err = 1;
}

if(file_exists($txt_user_file_dir)){
$error_msg[‘upload_txt_error’] = ‘<p class=”text-danger”>You have already uploaded a Text file to verify your ID! No need to upload and verify again!</p>’;
$upload_err = 1;
}

if($upload_err == 0){

if(is_uploaded_file($_FILES[“id_verification_video_file”][“tmp_name”]) && is_uploaded_file($_FILES[“id_verification_audio_file”][“tmp_name”]) && is_uploaded_file($_FILES[“id_verification_txt_file”][“tmp_name”]) && is_uploaded_file($_FILES[“id_verification_img_file”][“tmp_name”])){

if(move_uploaded_file($video_file_tmp,$video_user_file_dir)){
/// rename($video_user_file_dir , $video_directory.’/’.$user.’_id_verification.’.$video_file_ext);
}
if(move_uploaded_file($video_file_tmp,$audio_user_file_dir)){
// rename($video_user_file_dir , $audio_directory.’/’.$user.’_id_verification.’.$audio_file_ext);
}
if(move_uploaded_file($txt_file_tmp,$txt_user_file_dir)){
//rename($txt_user_file_dir , $text_directory.’/’.$user.’_id_verfication.’.$txt_file_ext );
}
if(move_uploaded_file($img_file_tmp,$txt_user_file_dir)){
//rename($img_user_file_dir , $img_directory.’/’.$user.’_id_verification.’.$img_file_ext);
}
$success_msg = ‘Files have been uploaded successfully!’;
}else{
$error_msg = ‘Files failed in uploading! File upoload attack could be the reason!’;
}
}
}
}
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<title>Confirm Id Upload</title>
<!—- Lato Font Family —>
<link href=”https://fonts.googleapis.com/css?family=Roboto” rel=”stylesheet”>
<!— Custom css —>
<link rel=”stylesheet” type=”text/css” href=”./css/custom.css” />
<script src=”https://code.jquery.com/jquery-3.4.1.min.js” integrity=”sha256-CSXorXvZcTkaix6Yvo6HppczGetbyMGWSF1Bw8HfCJo=”
crossorigin=”anonymous”></script>
<script src=”https://www.google.com/recaptcha/api.js” async defer></script>
</head>
<body>
<section class=”section confim-id-page”>
<div class=”container”>
<div class=”page-wapper”>
<div class=”page-title”>
<h3><?php $site_name ?>ID Video Verification Form</h3>
<p>Please upload your video for your ID Confirmation</p>
</div>
<?php if(isset($error_msg) && !empty($error_msg)){ echo $error_msg[‘all’];} ?>
<?php if(isset($error_msg[‘upload_video_error’]) && !empty(
$error_msg[‘upload_video_error’])){ echo $error_msg[‘upload_video_error’];} ?>
<?php if(isset($success_msg) && !empty($success_msg)){ echo ‘<p class=”alert-success”>’.$success_msg.'</p>’;} ?>
<?php if(isset($error_msg) && !empty($error_msg)){ echo ‘<p class=”alert-success”>’.$error_msg.'</p>’;} ?>
<form method=”POST” action=”” enctype=”multipart/form-data” id=”videoUploadForm” name=”videoUploadForm”>
<div class=”form-group”>
<label class=”control-label”>Text File</label>
<div class=”fileInput”>
<input type=”file” name=”id_verification_txt_file” id=”id_verification_txt_file” class=”form-control custom-file-input” value=”uploaded ‘Id Verification Text File.'” required />
</div>
<?php if(isset($error_msg[‘txt_error’]) && $error_msg[‘txt_error’]!=”){ echo $error_msg[‘txt_error’]; } ?>
<?php if(isset($error_msg[‘txt_file_size_err’]) && $error_msg[‘txt_file_size_err’]!=”){ echo $error_msg[‘txt_file_size_err’]; } ?>
<?php if(isset($error_msg[‘upload_txt_error’]) && $error_msg[‘upload_txt_error’]!=”){ echo $error_msg[‘upload_txt_error’]; } ?>
<p id=”error1″ class=”text-danger” style=”display:none; color:#FF0000;”>
Invalid Format! Only Format of text, doc and pdf files extension are allowed.
</p>
<p id=”error2″ class=”text-danger” style=”display:none; color:#FF0000;”>
Maximum File Size Limit is 100MB.
</p>
</div>
<div class=”form-group”>
<label class=”control-label”>Video File</label>
<div class=”fileInput”>
<input type=”file” name=”id_verification_video_file” id=”id_verification_video_file” class=”form-control custom-file-input” value=”uploaded ‘Id Verification Video File.'” required>
</div>
<?php if(isset($error_msg[‘video_error’]) && $error_msg[‘video_error’]!=”){ echo $error_msg[‘video_error’]; } ?>
<?php if(isset($error_msg[‘video_file_size_err’]) && $error_msg[‘video_file_size_err’]!=”){ echo $error_msg[‘video_file_size_err’]; } ?>
<?php if(isset($error_msg[‘upload_video_error’]) && $error_msg[‘upload_video_error’]!=”){ echo $error_msg[‘upload_video_error’]; } ?>
<p id=”error3″ class=”text-danger” style=”display:none; color:#FF0000;”>
Invalid Format! Only Format of mp4,ogg,wmv,flv and avi and wav files extension are allowed.
</p>
<p id=”error4″ class=”text-danger” style=”display:none; color:#FF0000;”>
Maximum File Size Limit is 100MB.
</p>
</div>
<div class=”form-group”>
<label class=”control-label”>Audio File</label>
<div class=”fileInput”>
<input type=”file” name=”id_verification_audio_file” id=”id_verification_audio_file” class=”form-control custom-file-input” value=”uploaded ‘Id Verification Audio File.'” required />
</div>
<?php if(isset($error_msg[‘audio_error’]) && $error_msg[‘audio_error’]!=”){ echo $error_msg[‘audio_error’]; } ?>
<?php if(isset($error_msg[‘audio_file_size_err’]) && $error_msg[‘audio_file_size_err’]!=”){ echo $error_msg[‘audio_file_size_err’]; } ?>
<?php if(isset($error_msg[‘upload_audio_error’]) && $error_msg[‘upload_audio_error’]!=”){ echo $error_msg[‘upload_audio_error’]; } ?>
<p id=”error5″ class=”text-danger” style=”display:none; color:#FF0000;”>
Invalid Format! Only Format of mp3 and wav files extension are allowed.
</p>
<p id=”error6″ class=”text-danger” style=”display:none; color:#FF0000;”>
Maximum File Size Limit is 100MB.
</p>
</div>
<div class=”form-group”>
<label class=”control-label”>Image File</label>
<div class=”fileInput”>
<input type=”file” name=”id_verification_img_file” id=”id_verification_img_file” class=”form-control custom-file-input” value=”uploaded ‘Id Verification Image File.'” required>
</div>
<?php if(isset($error_msg[‘img_error’]) && $error_msg[‘img_error’]!=”){ echo $error_msg[‘img_error’]; } ?>
<?php if(isset($error_msg[‘img_file_size_err’]) && $error_msg[‘img_file_size_err’]!=”){ echo $error_msg[‘img_file_size_err’]; } ?>
<?php if(isset($error_msg[‘upload_img_error’]) && $error_msg[‘upload_img_error’]!=”){ echo $error_msg[‘upload_img_error’]; } ?>
<p id=”error7″ class=”text-danger” style=”display:none; color:#FF0000;”>
Invalid Format! Only Format of jpeg,png,jpeg and gif files extension are allowed.
</p>
<p id=”error8″ class=”text-danger” style=”display:none; color:#FF0000;”>
Maximum File Size Limit is 100MB.
</p>
</div>
<div class=”g-recaptcha” data-sitekey=”6Le-eXUUAAAAAG7zq34Q9cGiDQEmL-VxXrMzHEf4″></div>
<br/>
<button type=”submit” id=”upload” class=”btn btn-submit” name=”id_verification_video_file_submit”>Submit</button>
</form>
</div>
</div>
</section>
</body>
</html>

<!–
<?php
include ‘footer_account.php’; //Required on all webpages of the Account.
?> –>
<script type=”text/javascript”>
$(function(){

$(‘#videoUploadForm’).on(‘submit’,function(){
if(grecaptcha && grecaptcha.getResponse().length < 1){
alert(‘Captcha is required’);
return false;
}
});

//$(‘button[type=”submit”]’).prop(“disabled”, true);
var a = 0,b=0,c=0,d=0;

$(‘#id_verification_txt_file’).bind(‘change’, function() {
if ($(‘button:submit’).attr(‘disabled’,false)){
$(‘button:submit’).attr(‘disabled’,true);
}
var ext = $(‘#id_verification_txt_file’).val().split(‘.’).pop().toLowerCase();
if ($.inArray(ext, [‘txt’,’doc’,’pdf’,’docx’]) == -1){
$(‘#error1’).slideDown(“slow”);
$(‘#error2’).slideUp(“slow”);
a=0;
}else{
var text_file = (this.files[0].size);
if (text_file > 100000000){
$(‘#error2’).slideDown(“slow”);
a=0;
}else{
a=1;
$(‘#error2’).slideUp(“slow”);
}
$(‘#error1’).slideUp(“slow”);
if (a==1){
$(‘button:submit’).attr(‘disabled’,false);
}
}
});

/*—- Video files extension —*/
$(‘#id_verification_video_file’).bind(‘change’, function() {
if ($(‘button:submit’).attr(‘disabled’,false)){
$(‘button:submit’).attr(‘disabled’,true);
}
var ext = $(‘#id_verification_video_file’).val().split(‘.’).pop().toLowerCase();
if ($.inArray(ext, [‘mp4′,’wav’,’ogg’,’flv’,’wmv’,’avi’]) == -1){
$(‘#error3’).slideDown(“slow”);
$(‘#error4’).slideUp(“slow”);
a=0;
}else{
var text_file = (this.files[0].size);
if (text_file > 100000000){
$(‘#error4’).slideDown(“slow”);
a=0;
}else{
a=1;
$(‘#error4’).slideUp(“slow”);
}
$(‘#error3’).slideUp(“slow”);
if (b==1){
$(‘button:submit’).attr(‘disabled’,false);
}
}
});

/*—- Audio Files extension —*/
$(‘#id_verification_audio_file’).bind(‘change’, function() {
if ($(‘button:submit’).attr(‘disabled’,false)){
$(‘button:submit’).attr(‘disabled’,true);
}
var ext = $(‘#id_verification_audio_file’).val().split(‘.’).pop().toLowerCase();
if ($.inArray(ext, [‘mp3′,’wav’]) == -1){
$(‘#error5’).slideDown(“slow”);
$(‘#error6’).slideUp(“slow”);
c=0;
}else{
var audio_file = (this.files[0].size);
if (audio_file > 100000000){
$(‘#error6’).slideDown(“slow”);
c=0;
}else{
c=1;
$(‘#error6’).slideUp(“slow”);
}
$(‘#error5’).slideUp(“slow”);
if (c==1){
$(‘button:submit’).attr(‘disabled’,false);
}
}
});

/*— Image files extension are allowed —*/
$(‘#id_verification_img_file’).bind(‘change’, function() {
if ($(‘button:submit’).attr(‘disabled’,false)){
$(‘button:submit’).attr(‘disabled’,true);
}
var ext = $(‘#id_verification_img_file’).val().split(‘.’).pop().toLowerCase();
if ($.inArray(ext, [‘jpg’,’png’,’gif’,’jpeg’]) == -1){
$(‘#error7’).slideDown(“slow”);
$(‘#error8’).slideUp(“slow”);
d=0;
}else{
var img_file = (this.files[0].size);
if (text_file > 100000000){
$(‘#error8’).slideDown(“slow”);
d=0;
}else{
d=1;
$(‘#error8’).slideUp(“slow”);
}
$(‘#error5’).slideUp(“slow”);
if (d==1){
$(‘button:submit’).attr(‘disabled’,false);
}
}
});
});
</script>
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@VITSUSAMay 27.2019 — @site-developer#1604038 You should ask your questions one by one which helps you to know the answers in detail.
×

Success!

Help @site-developer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...