0
每當用戶點擊提交,它應該檢查並看看提交按鈕是否被擊中。出於某種原因,雖然它只是忽略它。基本上我想要做的是檢查用戶是否上傳了圖片,然後檢查他們上傳的圖片。然而,這似乎並沒有工作:(這裏是我的代碼:POST不檢查按鈕表單提交
<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
}
}
}
}
}
}
}
?>