class uploadrouter extends controller {
function webimages() {
$img = c("img"); // 載入 img 類別
$img->setinfo(array(
"files" => "upload", // 上傳 input name
"uploadpath" => $GLOBALS['config']['webprojectpath']."upimages/",
"icopath" => $GLOBALS['config']['webprojectpath']."upimages/",
"icowidth" => "128",
"icoheight" => "98",
"fangpath" => $GLOBALS['config']['webprojectpath']."upimages/_ico/",
"fangsize" => "75",
"nzsize" => "180",
"uploadsize" => 420000
))->setbasename($_FILES['upload']['name'], true)->init();
if($img->upload(array('fix_side'))) { // 參數決定產生哪種縮圖
echo "上傳成功";
} else {
echo "上傳失敗: " . $img->message;
}
}
}
<form method="post" enctype="multipart/form-data" action="?app=upload&controller=uploadrouter&action=webimages">
<input type="file" name="upload" id="upload" />
<input type="submit" value="上傳圖片" />
</form>
完整 framework/lib/img.class.php 可從專案原始碼取得:QueryPHP 下載頁