Uploads Multiple image using PHP

              To upload Multiple file using PHP 


<?php
if(isset($_FILES['files'])){
$errors= array();
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){
$file_name = $key.$_FILES['files']['name'][$key];
$file_size =$_FILES['files']['size'][$key];
$file_tmp =$_FILES['files']['tmp_name'][$key];
$file_type=$_FILES['files']['type'][$key];
if($file_size > 2097152){
$errors[]='File size must be less than 2 MB';
}
$query="INSERT into upload_data (`USER_ID`,`FILE_NAME`,`FILE_SIZE`,`FILE_TYPE`) VALUES('$user_id','$file_name','$file_size','$file_type'); "; $desired_dir="user_data";
if(empty($errors)==true){
if(is_dir($desired_dir)==false){
mkdir("$desired_dir", 0700);
// Create directory if it does not exist
}
if(is_dir("$desired_dir/".$file_name)==false){ move_uploaded_file($file_tmp,"user_data/".$file_name);
}else{
//rename the file if another one exist
$new_dir="user_data/".$file_name.time();
rename($file_tmp,$new_dir) ;
}
mysql_query($query);
}else{
print_r($errors);
}
}
if(empty($error)){
echo "Success";
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="files[]" multiple="" />
<input type="submit"/></form>


Code By Harshit Shingala

Comments

  1. This site is help full for every person and easily get money through bitcoin atm card. please visit this site for bitcoin atm card ranking.you can change any money into another currency in any where in the world.

    ReplyDelete
  2. There is no better idea of keeping your mobile loaded with balance all the time. If you are also looking for any useful way to utilize your top up phone with bitcoin then hurry up and avail our service as much as can. There is no limit of it. Make your mobile life happier with balance recharge through NETELL.NET. COME SOON .THANK YOU .

    ReplyDelete
  3. Hey there, You have done a fantastic job. I’ll definitely dig it and personally suggest to my friends. I am confident they will be benefited from this web site.

    AWS Course in Chennai

    AWS Course in Bangalore

    AWS Course in Hyderabad

    AWS Course in Coimbatore

    AWS Course

    AWS Certification Course

    AWS Certification Training

    AWS Online Training

    AWS Training

    ReplyDelete
  4. After reading your blog I was amazed. The blog was explained clearly. And I hope all other readers will understand and experience how I felt after reading such a wonderful blog.
    acte reviews

    acte velachery reviews

    acte tambaram reviews

    acte anna nagar reviews

    acte porur reviews

    acte omr reviews

    acte chennai reviews

    acte student reviews

    ReplyDelete
  5. Python is the perfect programming language for people without any coding experience. It has a simple syntax, which makes it very accessible to beginners. Scripts written in Python are “human-friendly”: you can read Python code as you would read English commands.thanks lot!!

    Android Training in Chennai

    Android Online Training in Chennai

    Android Training in Bangalore

    Android Training in Hyderabad

    Android Training in Coimbatore

    Android Training

    Android Online Training

    ReplyDelete
  6. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing

    Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog

    it is really explainable very well and i got more information from your blog.

    ReplyDelete

Post a Comment

Popular Posts