<?php
function D_image_upload1($filename, $path="tmp",$target_file ,$maxsize=300000) {
  if(isset($_FILES[$filename]["name"]) && !empty($_FILES[$filename]["name"])) {$return["info"]=$_FILES;
  $target_dir = "CONTENT/UPLOAD/".$path."/";$ext = pathinfo($_FILES[$filename]["name"], PATHINFO_EXTENSION);
  if($target_file == ""){ $uploadOk="";
    $target_file=time()."_".rand(1000, 9999).'.'.$ext;$return["name"]=$target_file;
    $target_file = $target_dir.$target_file;}
  else $target_file = $target_dir.$target_file;
    if($_FILES[$filename]["size"]==0){ $check = false; $uploadOk .= "Check Max upload limit.apache";}
      else $check = getimagesize($_FILES[$filename]["tmp_name"]);
    if($check !== false) { $return["mime"]=$check["mime"]; }
      else {$uploadOk .= "File is not an image.";    }
    if ($_FILES[$filename]["size"] > $maxsize) { $uploadOk .= "Sorry, your file is too large.";}
    else {
        if (move_uploaded_file($_FILES[$filename]["tmp_name"], $target_file)) {
            $uploadOk = "The file ". basename( $_FILES[$filename]["name"]). " has been uploaded.";$return["D_image_upload1"] = "ok";
        } else {
            $uploadOk .= "Sorry, there was an error Moving the uploaded file.";//print_r($_FILES);
        }
    }
    $return["error"]=$uploadOk;
    return $return;// $return["info"] $return["name"] $return["mime"]
  }
}
?>
