Please help me to solve this problem.
**
public function uploadPhoto($file)
{
if(!empty($file)){
$fileTempPath=$file['tmp_name'];
$fileName=$file['name'];
$fileType=$file['type'];
$fileNameCmps=explode('.',$fileName);
$fileExtension=strtolower(end($fileNameCmps));
$newFileName=md5(time().$fileName) . '.' .
$fileExtension;
$allowedExtn=["png","jpg","jpeg"];
if(in_array($fileExtension,$allowedExtn))
{
$uploadFileDir=getcwd().'/uploads';
$destFilePath=$uploadFileDir . $newFileName;
if(move_uploaded_file($fileTempPath,$destFilePath)){
return $newFileName;
}
}
}
}**
this is how I send data to parameters
** if($conf == $_SESSION['randomNum']) {
//create object of user class
require_once 'C:\xampp\htdocs\MEDICALCENTERPROJECT\app\libraries\User.php';
$obj = new User();
$obj->connect();
$img = "";
if($pic == "")
{
$img = "null";
}
else{
$img = $obj->uploadPhoto($pic);
}**
I tried many times to understand the error but I could not do. Here the error is shown in line 111 its mean $fileTempPath=$file['tmp_name']; in this line. Please help me to solve this.
this is how I sent data using ajax
**$(document).ready(function() {
$("#success").hide();
$("#con").click(function() {
let confirm = $("#ccode").val();
let isTrue = "false";
let username = $("#pusername").val();
let email = $("#pemail").val();
let mobile = $("#pmobile").val();
let addrs = $("#paddress").val();
let id = $("#pidno").val();
let pswd = $("#ppassword").val();
let c_pswd = $("#pcpassword").val();
let pic = $("#puserphoto").val();
let data = new FormData("#addformSign");
$.ajax({
url: "./Patials/sendEmailVerifyCode.php", //"./Patials/ajax.php",
type: "POST",
data: {
conf: confirm,
isTrue: isTrue,
username: username,
email: email,
mobile: mobile,
addrs: addrs,
id: id,
pswd: pswd,
pic: pic,
},
success: function(response) {
alert(response);
if (response == confirm) {
$("#emailCon").modal("show");
$("#confirm").hide();
$("#success").show();
} else {
$("#ccode").css({
"borderColor": "red",
"backgroundColor": "rgba(253, 127, 127, 0.5)"
});
$("#confirm").show();
$("#errMsg").text("Invalid Code!");
}
},
error: function(request, error) {
console.log(arguments);
console.log("Erro" + error);
$("#confirm").show();
},
});
});
**
let confirm = $("#ccode").val(); this input field is not in the same form.