PHP MySQL在图像上传之前调整大小

时间:2016-12-31 17:15:09

标签: php mysql upload resize

我想知道如何在我的代码中设置调整大小插件。我有上传图像的代码,它工作得很好,但我不知道如何调整它。如果有人能帮助我,我会很高兴的。谢谢!

if(isset($_FILES['images'])){
if(count($_FILES['images']['name'])){



$errors= array();
foreach($_FILES['images']['tmp_name'] as $key => $tmp_name){
    $file_name = $key.$_FILES['images']['name'][$key];
    $file_tmp =$_FILES['images']['tmp_name'][$key];
    $filePath = "img/zoekertjes/";

    $desired_dir="img/zoekertjes";
    if(empty($errors)==true){
        if(is_dir($desired_dir)==false){
            mkdir("$desired_dir", "img/zoekertjes",true);       
        }
        if(is_dir("$desired_dir/".$file_name)==false){
        move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
        }else{  // rename the file if another one exist
            $new_dir="$desired_dir/".$file_name.time();
             rename($file_tmp,$new_dir);                
        }
          $query="INSERT INTO `t_images` (d_image_naam, d_image_images) VALUES ('$_POST[name]','$file_name')";
     mysqli_query($db,$query);          
    }
    else
    {

     print_r($errors);

    }
}
if(empty($errors)){
echo "<div id='succes_msg'>Zoekertje succes toegevoegd.</div>";

} 

 }else{
    echo "<div id='error_msg'>Zoekertje kan helaas niet worden toegevoegd. Gelive later proberen.</div>";
}
}

0 个答案:

没有答案