Unable To Call Php From Html Form
I want to call 'phpControls.php' from home.html to upload the browsed image in to a desired folder. I inspected the page in Chrome, it shows that the Upload button is not calling t
Solution 1:
Your PHP is looking for the wrong value. You have your HTML button set to name="submitBtn"
, the name attribute is what you're selecting in PHP when you use $_POST["submit"]
.
So you need to change this:
if(isset($_POST["submit"])) {
To this:
if(isset($_POST["submitBtn"])) {
Not sure if this is the only issue, but it should at least make your code run. :)
Solution 2:
Most probably the only reason is the wrong value being checked by isset function. Replace your phpControls.php code to the following.
<?phpecho"Enter php";
$target_dir = "SharedFolder/";
$target_file = $target_dir . basename($_FILES["browseFile"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake imageif(isset($_POST["submitBtn"])) {
$check = getimagesize($_FILES["browseFile"]["tmp_name"]);
if($check !== false) {
echo"File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo"File is not an image.";
$uploadOk = 0;
}
}
echo"Exit php";
?>
Post a Comment for "Unable To Call Php From Html Form"