I have one form in my bootstrap website My HTML CODE is this :my HTML & Javascript code is shown below. my file is not uploading into the folder .
To see the screenshot of the error please click below link
// JavaScript Document
$(document).ready(function () {
jQuery("#register-form").validationEngine();
$("#register-form").on("submit", function (e)
{
e.preventDefault();
if ($("#register-form").validationEngine('validate'))
{
var form_data = $("form").serialize();
$.post("insert1.php", {form_values: form_data}, function (data)
{
var Data = jQuery.parseJSON(data);
$(".registration_form").hide(200);
$(".success_msg").show(200, function ()
{
$(".result").show();
$("td#First_name").html(Data[0].First_name);
$("#Last_name").html(Data[0].Last_name);
$("#Email").html(Data[0].Email);
$("#Contact_no").html(Data[0].Contact_no);
$("#Jobseeker_type").html(Data[0].Jobseeker_type);
});
});
} else {
return false;
}
});
});
<html>
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/validationEngine.jquery.css">
</head>
<div class="registration_form">
<form class="form-horizontal" role="form" action="insert1.php" method="POST" name="register-form" id="register-form" enctype="multipart/form-data">
<div class="form-group">
<label for="fname" class="col-sm-2 control-label">First Name:</label>
<div class="col-sm-6">
<input type="text" name="fname" class="form-control" id="fname" placeholder="First Name" data-validation-engine="validate[required]" data-errormessage-value-missing="First Name is required!" >
</div>
</div>
<div class="form-group">
<label for="lname" class="col-sm-2 control-label">Last Name:</label>
<div class="col-sm-6">
<input type="text" name="lname" class="form-control" id="lname" placeholder="Last Name" data-validation-engine="validate[required]" data-errormessage-value-missing="Last Name is required!" >
</div>
</div>
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Email:</label>
<div class="col-sm-6">
<input type="email" name="username" class="form-control" id="username" placeholder="Email" data-validation-engine="validate[required,custom[email]]" data-errormessage-value-missing="Your Email is required!" >
</div>
</div>
<div class="form-group">
<label for="contact" class="col-sm-2 control-label">Contact No:</label>
<div class="col-sm-6">
<input type="tel" name="contact" class="form-control" id="contact" placeholder="Phone" data-validation-engine="validate[required,custom[phone]]" data-errormessage-value-missing="Your Contact No is required!" >
</div>
</div>
<div class="form-group">
<label for="" class="col-sm-2 control-label">Jobseeker Type:</label>
<div class="col-sm-6">
<label class="radio-inline">
<input type="radio" name="jobseeker" id="jobseeker1" value="student" data-validation-engine="validate[required]"
data-errormessage-value-missing="Please Select any one option">Student
</label>
<label class="radio-inline">
<input type="radio" name="jobseeker" id="jobseeker2" value="fresher" data-validation-engine="validate[required]" data-errormessage-value-missing="Please Select any one option">Fresher
</label>
<label class="radio-inline">
<input type="radio" name="jobseeker" id="jobseeker3" value="experienced" data-validation-engine="validate[required]" data-errormessage-value-missing="Please Select any one option">Experienced
</label>
</div>
</div>
<div class="form-group">
<label for="" class="col-sm-2 control-label">Upload your Resume:</label>
<div class="col-sm-6">
<input type="file" name="image" id="image" class="form-control" data-validation-engine="validate[required, custom[checkFileType[image/jpeg|image/png]]]" data-errormessage-value-missing="Please upload your Resume!" >
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" id="register" name="submit">Submit</button>
</div>
</div>
</form>
</div><!-- end for class "registration_form" --
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="js/jquery.validationEngine.js"></script>
my php file is shown here
<?php
$errors = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
$extensions = array("jpeg", "png");
$fileInfo = pathinfo($file_name);
$ipath = "resumes/" . uniqid() . '.' . $fileInfo['extension'];
move_uploaded_file($file_tmp, $ipath);
if (isset($_POST["form_values"])) {
$form_data = urldecode($_POST["form_values"]);
preg_match_all('#(\w+)=([^&=]*)(?:&|$)#', $form_data, $matches, PREG_SET_ORDER);
$result = array();
$i = 0;
foreach ($matches as $m) {
list(, $key, $value) = $m;
if (!strlen($value)) {
$i = (int) $key;
} else {
$result[$i][$key] = $value;
}
}
require_once("db1.php");
$fname = $result[0]["fname"];
$lname = $result[0]["lname"];
$username = ($result[0]["username"]);
$contact = $result[0]["contact"];
$jobseeker = $result[0]["jobseeker"];
$image = $result[0]["image"];
$sql_insert = "INSERT INTO users (First_name, Last_name, Email, Contact_no, Jobseeker_type) VALUES (
:fname,
:lname,
:username,
:contact,
:jobseeker
)";
try {
$query_insert = $db->prepare($sql_insert);
$result_insert = $query_insert->execute(array(
':fname' => $fname,
':lname' => $lname,
':username' => $username,
':contact' => $contact,
':jobseeker' => $jobseeker));
} catch (PDOException $ex) {
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
if ($result_insert) {
$last_insert_id = $db->lastInsertId();
$sql_select = "SELECT
First_name,
Last_name,
Email,
Contact_no,
Jobseeker_type
FROM users
WHERE
id = :id";
try {
$query_select = $db->prepare($sql_select);
$query_select->execute(array(':id' => $last_insert_id));
$results = $query_select->fetchAll(PDO::FETCH_ASSOC);
$json = json_encode($results);
echo $json;
} catch (PDOException $ex) {
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
//echo "You are successfully registered.";
} else {
echo "error occured";
}
}
?>
I am using jquery validation engine to validate MIME files i have included below code in my jquery.validationEngine.js file
case "checkFileType":
errorMsg = methods._checkFileType(field, rules, i, options);
break;
_checkFileType: function(field, rules, i, options)
{
//add to input tag: data-validation-engine="validate[required, custom[validateMIME[image/jpeg|image/png]]]"
var fileInput = field[0].files[0];
var MimeFilter = new RegExp(rules[3], 'i');
if (fileInput)
{
return MimeFilter.test(fileInput.type);
}
else
{
return true;
}
},
and below code into jquery.validationEngine-en.js
"checkFileType":
{
"regex": "none",
"alertText": "* Wrong file Type."
},
still file is not uploading in my "resume" folder i will appreciate quick reply