Whenever a user clicks submit it should check and see if the submit button was hit. For some reason though it is just ignoring it. Basically what I want to do it check and see if the user has uploaded a image, and then check the image they have uploaded. Yet it does not seem to work :( Here is my code:
<div class="col-xs-12">
<form action="" method="post" enctype="multipart/form-data">
<div class="col-xs-12" id="fileuploadbuttontitle">
Change Picture
</div>
<div class="col-xs-12" id="fileuploadbutton">
Select Image
<input type="file" name="image">
</div>
<div class="col-xs-12">
<button type="submit" name="uploadimage" id="fileuploadbuttonsubmit"> Upload Image </button>
</div>
</form>
<?php
if (isset($_POST["uploadimage"])) {
//variables
$target_dir = "pictures/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
//tests
$imagetest = False;
$imagesizetest = False;
$imageformattest = False;
//Checks to see if upload is a image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check == False) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> Photo is invalid. </div>
<?php
$imagetest = False;
}
else {
$imagetest = True;
//File Size
if ($_FILES["image"]["size"] > 15000) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> Photo is too big. Maxium 15 KB. </div>
<?php
$imagesizetest = False;
}
else {
$imagesizetest = True;
//File Format
if(($imageFileType == "jpg") or ($imageFileType == "png") or ($imageFileType == "jpeg") or ($imageFileType == "gif")) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> Photo is not a valid format. JPG, JPEG, PNG, or GIF. </div>
<?php
$imageformattest = False;
}
else {
$imageformattest = True;
//Final Check
if (($imagetest) and ($imagesizetest) and ($imageformattest)) {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file . "test")) {
?>
<meta http-equiv='refresh' content="0; url=http://localhost/postin'/profiles/<?php print utf8_decode($loggedin_session_permalink); ?>"
<?php
}
else {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
}
}
?>