//加入一個「上傳」文字框元件 $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new XoopsFormFile('上傳', 'pic', '2048000')); ``` 在新增或更新功能加入: ``` if(empty($honor_sn))$honor_sn=$xoopsDB->getInsertId(); if(!empty($_FILES['pic']['name'])){ include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $allowed = array('image/jpg','image/jpeg'); $target = XOOPS_ROOT_PATH."/uploads/"; $uploader = new XoopsMediaUploader($target, $allowed, 2048000); $uploader->setTargetFileName("{$honor_sn}.jpg"); $uploader->fetchMedia('pic',0); $uploader->upload(); } ``` 抓取圖檔資料: ``` if(file_exists(XOOPS_ROOT_PATH."/uploads/{$all['honor_sn']}.jpg")){ $all_data[$i]['pic']=true; } ``` 樣板套用: ``` <{$if $h.pic}> <{/if}> ```
if(empty($honor_sn))$honor_sn=$xoopsDB->getInsertId(); if(!empty($_FILES['pic']['name'])){ include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $allowed = array('image/jpg','image/jpeg'); $target = XOOPS_ROOT_PATH."/uploads/"; $uploader = new XoopsMediaUploader($target, $allowed, 2048000); $uploader->setTargetFileName("{$honor_sn}.jpg"); $uploader->fetchMedia('pic',0); $uploader->upload(); } ``` 抓取圖檔資料: ``` if(file_exists(XOOPS_ROOT_PATH."/uploads/{$all['honor_sn']}.jpg")){ $all_data[$i]['pic']=true; } ``` 樣板套用: ``` <{$if $h.pic}> <{/if}> ```
if(file_exists(XOOPS_ROOT_PATH."/uploads/{$all['honor_sn']}.jpg")){ $all_data[$i]['pic']=true; } ``` 樣板套用: ``` <{$if $h.pic}> <{/if}> ```
<{$if $h.pic}> <{/if}> ```
進階搜尋
52人線上 (20人在瀏覽線上書籍)
會員: 0
訪客: 52