library/Image.php
//compresspercent - the quality of the picture int 0-100F
the quality of the picture int 0-100F
the quality of the picture int 0 - 100F
public static function uploadImage($directory,$input_name,$submit_name,$compress = true,$width,$height,$compresspercent)
    {
        if(!is_dir($directory))
        {
            mkdir($directory,0777,true);
        }
        for($i = 0; $i<count($_FILES[$input_name]["name"]);$i++)
        {
            $target_dir = $directory."/";
            $target_file = $target_dir.basename($_FILES[$input_name]["name"][$i]);
            $uploadOk = 1;
            $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
            if(isset($_POST[$submit_name]))
            {
                $check = getimagesize($_FILES[$input_name]["tmp_name"][$i]);
                if($check !== false)
                {
                    $uploadOk = 1;
                }
                else
                {
                    $uploadOk = 0;
                }
            }
            if (file_exists($target_file))
            {
                $split_target_file = explode(".",$_FILES[$input_name]["name"][$i]);
                $split_target_file_count = count($split_target_file);
                $target_file = $target_dir;
                for($ii = 0; $ii<$split_target_file_count; $ii++)
                {
                    if($ii == 0) $target_file = $target_file.$split_target_file[$ii];
                    else if($ii != $split_target_file_count-1) $target_file.".".$split_target_file[$ii];
                    else if($ii == $split_target_file_count-1) $target_file = $target_file.date('Y-m-d h:i:s', time()).".".$split_target_file[$ii];
                }
                $uploadOk = 1;
            }
            if ($_FILES[$input_name]["name"][$i] > 5000000000)
            {
                $uploadOk = 0;
            }
            if ($uploadOk == 0)
            {                
            }
            else
            {
                if (move_uploaded_file($_FILES[$input_name]["tmp_name"][$i], $target_file))
                {
                    if($compress == true)
                    {
                        $name = Image::compressImage($target_file,$target_file,$width,$height,$compresspercent);
                    }                
                    return $name;
                }
                else
                {
                    return "false";
                }
            }
        }
    }
public static function uploadImage ( $ directory , $ input_name , $ submit_name , $ compress = true , $ width , $ height , $ compresspercent ) { if ( ! is_dir ( $ directory ) ) { mkdir ( $ directory , 0777 , true ) ; } for ( $ i = 0 ; $ i < count ( $ _FILES [ $ input_name ] [ " name " ] ) ; $ i ++ ) { $ target_dir = $ directory . " / " ; $ target_file = $ target_dir . basename ( $ _FILES [ $ input_name ] [ " name " ] [ $ i ] ) ; $ uploadOk = 1 ; $ imageFileType = pathinfo ( $ target_file , PATHINFO_EXTENSION ) ; if ( isset ( $ _POST [ $ submit_name ] ) ) { $ check = getimagesize ( $ _FILES [ $ input_name ] [ " tmp_name " ] [ $ i ] ) ; if ( $ check !== false ) { $ uploadOk = 1 ; } else { $ uploadOk = 0 ; } } if ( file_exists ( $ target_file ) ) { $ split_target_file = explode ( " . " , $ _FILES [ $ input_name ] [ " name " ] [ $ i ] ) ; $ split_target_file_count = count ( $ split_target_file ) ; $ target_file = $ target_dir ; for ( $ ii = 0 ; $ ii < $ split_target_file_count ; $ ii ++ ) { if ( $ ii == 0 ) $ target_file = $ target_file . $ split_target_file [ $ ii ] ; else if ( $ ii != $ split_target_file_count - 1 ) $ target_file . " . " . $ split_target_file [ $ ii ] ; else if ( $ ii == $ split_target_file_count - 1 ) $ target_file = $ target_file . date ( 'Y-m-d h:i:s' , time ( ) ) . " . " . $ split_target_file [ $ ii ] ; } $ uploadOk = 1 ; } if ( $ _FILES [ $ input_name ] [ " name " ] [ $ i ] > 5000000000 ) { $ uploadOk = 0 ; } if ( $ uploadOk == 0 ) { } else { if ( move_uploaded_file ( $ _FILES [ $ input_name ] [ " tmp_name " ] [ $ i ] , $ target_file ) ) { if ( $ compress == true ) { $ name = Image :: compressImage ( $ target_file , $ target_file , $ width , $ height , $ compresspercent ) ; } return $ name ; } else { return " false " ; } } } }
compresspercent - the quality of the picture int 0-100F
compresspercent - the quality of the picture int 0 - 100F
//print 'Here is some more debugging info:'; //print_r($_FILES); //print "</pre>"; //echo "File is an image - " . $check["mime"] . "."; //echo "File is not an image."; // Check if file already exists //echo "Sorry, file already exists."; //echo $split_target_file[0]; //echo $target_file; // Check file size //echo "Sorry, your file is too large."; // Check if $uploadOk is set to 0 by an error //echo $target_file; //echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file //echo $target_file; //echo $target_file; //echo $compress; //echo "Sorry, there was an error uploading your file.";