Here i am uploading data through a form which contains some input fields and one image. But i want to upload multiple images here instead of one image. I am attaching my php code here to upload the data and single image. Can anyone edit this code to add mutliple images. Name the next 2-3 images as post_icon1, post_icon2
Thanks in advance .......
<?php
$submit=$_POST['submit'];
$cat = array (
"1" => "Yes",
"2" => "No"
);
$post_roots = array (
"1" => "Select Yes (OR) No",
"2" => "Yes",
"3" => "No"
);
include('test.php');
if($submit=="Save"){
$cat_ids="";
$post_title= $_POST['post_title'];
$developer_name= $_POST['developer_name'];
$post_size= $_POST['post_size'];
$post_version= $_POST['post_version'];
$req_android= $_POST['req_android'];
$cats = $_POST['cat'];
$post_root= $_POST['post_root'];
$post_category= $_POST['post_category'];
$post_description= $_POST['post_description'];
$post_changes= $_POST['post_changes'];
$post_permision= $_POST['post_permision'];
$repl= $_POST['repl'];
$post_icon="";
if($post_category=="-1"){$post_category="";}
foreach ($cats as $catid){
$cat_ids.= $catid;
}
$success=true;
$allowedExts = array("jpg", "jpeg", "gif", "png", "bmp");
$extension = end(explode(".", $_FILES["post_icon"]["name"]));
if (is_uploaded_file($_FILES["post_icon"]["tmp_name"])) {
//echo "Type: " .$_FILES["post_icon"]["type"]. "<br>";
if ((($_FILES["post_icon"]["type"] == "image/gif") || ($_FILES["post_icon"]["type"] == "image/jpeg") || ($_FILES["post_icon"]["type"] == "image/png") || ($_FILES["post_icon"]["type"] == "image/pjpeg")) && in_array($extension, $allowedExts)){
//&& ($_FILES["post_icon"]["size"] < 20000)
if ($_FILES["post_icon"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["post_icon"]["error"] . "<br />";
$msg= "Return Code: " . $_FILES["post_icon"]["error"] . "<br />";
$success=false;
}
else
{
if (file_exists("upload/posts/" . $_FILES["post_icon"]["name"]) && $repl<>1)
{
//echo $_FILES["post_icon"]["name"] . " already exists. ";
$msg = $_FILES["post_icon"]["name"] . " already exists. ";
$success=false;
}
else
{
move_uploaded_file($_FILES["post_icon"]["tmp_name"], "upload/posts/" . $_FILES["post_icon"]["name"]);
$post_icon=$_FILES["post_icon"]["name"];
//echo "post Details added Successfully.<br>";
$success=true;
}
}
}else{
$msg= "Invalid file";
//echo "Invalid file";
$success=false;
}
}
echo "Sucess:$success<br><br>";
if($success==true){
//echo "Entered<br>";
$QUERY= "insert into post_submision (post_title, posticon, developer_name, post_size, post_version, req_des,post_description, post_changes, post_permision, post_recomend, post_category, post_root, datetime) values ('" .escapeChar($post_title). "','" .escapeChar($post_icon). "','" .escapeChar($developer_name). "','" .escapeChar($post_size). "','" .escapeChar($post_version). "','" .escapeChar($req_android). "','" .escapeChar($post_description). "','" .escapeChar($post_changes). "','" .escapeChar($post_permision). "','" .escapeChar($cat_ids). "','" .escapeChar($post_category). "','" .escapeChar($post_root). "',now())";
//echo "Query:$QUERY<br><br>";
$result = mysql_query($QUERY);
$post_title= "";
$developer_name= "";
$post_size= "";
$post_version= "";
$req_android= "";
$post_description= "";
$post_changes= "";
$post_permision= "";
$cats = "";
$post_category= "";
$post_root= "";
$repl= "";
//echo "REPLACE: $repl<br>";
//echo "post: " .$post_title. "<br>";
$post_icon="";
$msg= "post Details Successfully Added.";
}
}
?>