i have written a script to upload images,there are 2 input file upload to upload.. i have done validation in php to check which input is choosed or not so that table is not updated with blank if no image is choose.
Problem is that it update table if i choose both image..but not when 1 is choosed.
Code:
if ($_FILES["path"]["size"] > 0 && $_FILES["path1"]["size"] < 0) {
$allowedExts = array("jpg", "jpeg", "png");
$extension = end(explode(".", $_FILES["path"]["name"]));
//echo $extension;
if (($extension == "jpeg")
|| ($extension == "jpg")
|| ($extension == "png")
) {
if ($_FILES["path"]["error"] > 0) {
$msg = $_FILES["path"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["path"]["tmp_name"],
"../images/" . $_FILES["path"]["name"]);
}
$filename = "images/" . $_FILES["path"]["name"];
///update query
}
} else if ($_FILES["path"]["size"] < 0 && $_FILES["path1"]["size"] > 0) {
$allowedExts = array("jpg", "jpeg", "png");
$extension = end(explode(".", $_FILES["path1"]["name"]));
//echo $extension;
if (($extension == "jpeg")
|| ($extension == "jpg")
|| ($extension == "png")
) {
if ($_FILES["path1"]["error"] > 0) {
$msg = $_FILES["path1"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["path1"]["tmp_name"],
"../images/" . $_FILES["path1"]["name"]);
}
$filename1 = "images/" . $_FILES["path1"]["name"];
///update query
}
} else if ($_FILES["path"]["size"] < 0 && $_FILES["path1"]["size"] < 0) {
} else if ($_FILES["path"]["size"] > 0 && $_FILES["path1"]["size"] > 0) {
$allowedExts = array("jpg", "jpeg", "png");
$extension = end(explode(".", $_FILES["path"]["name"]));
//echo $extension;
if (($extension == "jpeg")
|| ($extension == "jpg")
|| ($extension == "png")
) {
if ($_FILES["path"]["error"] > 0) {
$msg = $_FILES["path"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["path"]["tmp_name"],
"../images/" . $_FILES["path"]["name"]);
}
$filename = "images/" . $_FILES["path"]["name"];
$allowedExtss = array("jpg", "jpeg", "png");
$extensions = end(explode(".", $_FILES["path1"]["name"]));
//echo $extension;
if (($extensions == "jpeg")
|| ($extensions == "jpg")
|| ($extensions == "png")
) {
if ($_FILES["path1"]["error"] > 0) {
$msgs = $_FILES["path1"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["path1"]["tmp_name"],
"../images/" . $_FILES["path1"]["name"]);
}
$filename1 = "images/" . $_FILES["path1"]["name"];
///update query
}
header("Location: index.php?p=setings");
exit;
I have checked each and every thing but no error found.