I am uploading the profile pic and banner image in the folder and name into the database. I have added the below 2 files and inserted them into the database and folder.
Now, I don't want to update the file but when I submit then I am getting the validation error message. I know my file type is empty and I am previewing the image.
I have to set the validation if the file is empty.
$("form[name='myprofile']").validate({
rules: {
file1: {
required: true,
extension: "png|jpe?g",
},
file2: {
required: true,
extension: "png|jpe?g",
}
},
messages: {
file1: {
extension: "Please upload jpeg or png image",
},
file2: {
extension: "Please upload jpeg or png image",
}
},
submitHandler: function(form) {
form.submit();
}
});
input[type="file"] {
padding-bottom: 45px;
}
<form action="process.php" method="post" name="myprofile" enctype="multipart/form-data" id="myprofile">
<input type="file" name="file1"><br />
<input type="hidden" name="file1" value="<?php echo $info['file1'];?>">
<!--store image name image-->
<img src="assets/images/<?php echo $info['file1'];?>">
<!--Preview image-->
<input type="file" name="file2"><br />
<input type="hidden" name="file2" value="<?php echo $info['file2'];?>">
<!--store image name image-->
<img src="assets/images/<?php echo $info['file2'];?>">
<!--Preview image-->
<input type="submit" name="submit" value="submit">
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/additional-methods.min.js"></script>