Here is my issue: I am trying to upload a photo and resume of users for my job searching website. I am able to upload both the files into the directory but not able to store the file names into the data base. Please help me! I am sure it can be fixed. Help me out please!! This is my php code..
<?php
if(isset($_POST['pro'])) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email2'];
$mobno = $_POST['mob'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$nation = $_POST['nation'];
$state = $_POST['state'];
$quali = $_POST['quali'];
$role = $_POST['role'];
$clg = $_POST['clg'];
$exp = $_POST['exp'];
$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
$field3 = $_POST['field3'];
$field4 = $_POST['field4'];
$pic = basename($_FILES['userpic']['name']);
$filename = basename($_FILES['userfile']['name']);
$folder_name="uploads";
if (!file_exists($folder_name))/* Check folder exists or not */
{
@mkdir($folder_name, 0777);/* Create folder by using mkdir function */
echo "Folder Created";/* Success Message */
}
$destination = 'uploads/' . $pic;
$destination1 = 'uploads/' . $filename;
$extension = pathinfo($pic, PATHINFO_EXTENSION);
$extension1 = pathinfo($filename, PATHINFO_EXTENSION);
$file1 = $_FILES['userpic']['tmp_name'];
$size1 = $_FILES['userpic']['size'];
$file = $_FILES['userfile']['tmp_name'];
$size = $_FILES['userfile']['size'];
if (!in_array($extension1, ['zip', 'pdf', 'docx']) && !in_array($extension, ['jpg', 'png'])) {
echo "You file extension must be .zip,.png or .docx for resume and .jpg or .png for photo";
} elseif ($_FILES['userfile']['size'] > 1000000 && $_FILES['userpic']['size'] > 1000000) { // file shouldn't be larger than 1Megabyte
echo "File too large!";
} else {
// move the uploaded (temporary) file to the specified destination
if (move_uploaded_file($file, $destination1) && move_uploaded_file($file1, $destination)) {
mysqli_query($con, "INSERT INTO `profile` (`pro_id`,`first_name`,`last_name`,`email`,`mobno`,`date_of_birth`,`gender`,`nation`,`state`,`qualification`,`role`,`institution`,`year_of_exp`,`field1`,`field2`,`field3`,`field4`,`pic`,`file`) VALUES ('','$fname','$lname','$email','$mobno','$dob','$gender','$nation','$state','$quali','$role','$clg','$exp','$field1','$field2','$field3','$field4','$pic',$filename')");
echo "<center>Profile completed successfully!!</center>";
}
}
}
?>