線上書籍

Home

[982]PHP網站開發 進階應用技巧

一、EasyPhpThumbnail Class縮圖物件

1.http://www.mywebmymail.com/?q=content/easyphpthumbnail-class
include_once('easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Createthumb('image.jpg');
2.存成檔案:
$thumb -> Chmodlevel = '0755';
$thumb -> Thumblocation = "myfiles/_thumbs/Images/";
$thumb -> Thumbprefix = '';
$thumb -> Createthumb("myfiles/{$file}",'file');
3.指定大小(三選一即可)
$thumb -> Thumbsize = 160;    //長邊上限160
$thumb -> Thumbwidth=160 ;   //寬上限160
$thumb -> Thumbheight=100 ;  //高上限100
4.製作陰影
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Shadow = true;
5.製作圓角(模式[0關閉,1直角,2圓角],圓角程度,隨機,左上,左下.右上,右下)
$thumb -> Clipcorner = array(2,5,0,1,1,1,1);
6.加上外框
$thumb -> Framewidth = 10;
$thumb -> Framecolor = '#FFFFFF';
7.加上裝訂特效
$thumb -> Binder = true;
$thumb -> Binderspacing = 8;
8.加上浮水印(僅能用png檔)
$thumb -> Watermarkpng = 'watermark.png';
$thumb -> Watermarkposition = '50% 50%';  //位置
$thumb -> Watermarktransparency = 70;       //透明度(數字越大,越不透明)
9.加上文字浮水印(圖片版權)
$thumb -> Copyrightfonttype = 'cwheib.ttf';
$thumb -> Copyrightfontsize = 12;
$thumb -> Copyrighttextcolor = '#FFFFFF';  //不設會自動偵測
$thumb -> Copyrighttext = 'http://ck2tw.net 點兩下';
$thumb -> Copyrightposition = '0% 95%';

二、整合型上傳工具

1.class.upload.php(http://www.verot.net/res/sources/class.upload.html)
2.jquery.MultiFile(http://www.fyneworks.com/jquery/multiple-file-upload/)
3.lytebox(http://www.dolem.com/lytebox/)
(1) 先建立資料表files_center
(2) 在用到上傳的檔案,加入此行:include_once "up_file.php";
(3) 在上傳的表單加入屬性:enctype='multipart/form-data'
(4)  在上傳的表單加入底下引入相關檔案的語法:
<script src="upload/jquery-1.3.2.min.js"></script>
<script src="upload/jquery.MultiFile.js"></script>
(5) 在上傳的表單加入該上傳欄位:<input type='file' name='upfile[]' class='multi' maxlength=1>".list_del_file($col_name,$col_sn)."
(6) 在儲存或更新的動作中加入上傳函數:upload_file($col_name,$col_sn);
(7) 顯示所有圖片:show_files($col_name,$col_sn);
a.show_files(欄位,編號,是否縮圖,顯示模式filename、num,顯示描述,顯示下載次數)
(8) 刪除資料時,在刪除程式中,最後加入刪除檔案函數:
del_files($files_sn,$col_name,$col_sn);