PHP code example of exinfinite / img-upload

1. Go to this page and download the library: Download exinfinite/img-upload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

exinfinite / img-upload example snippets


composer 

//支援jpg、jpeg、png
$img = new Exinfinite\ImgUpload\ImgExif("upload dir", "name of input[type=file]");

$fileinfo = $img->setFitSize(1920)->save();//max-width:1920

$filename = "filename without extension";//程式自動判斷檔案類型
$img->getDimension();//圖檔尺寸
$img->getExif();//EXIF資訊
$img->md5Hash();//圖檔hash
$img->sizeLimit("10m");//default:20m
$img->mkdir("dir path");//建立資料夾
$img->setFitSize("max width", "max height");//自動縮圖,0為不限制
$img->save("dir_path/{$filename}");//儲存處理後的檔案
$img->upload("dir_path/{$filename}");//上傳原始圖檔,若需要此操作,需放最後執行