phpcms怎么上傳文件

phpcms怎么上傳文件

phpcms怎么上傳文件?phpcms前端頁面上傳文件

PHPCMS其實有一個叫做附件的模塊,上傳用的就是這個東西,現在我們來看一下對應的文件:phpcmsmodulesattachment attachments.php就是這個文件,大概在29行上(我用的PHPCMS版本號是Phpcms V9.5.8 Release 20140929)有下面一個方法:

public?function?upload()?{?$grouplist?=?getcache('grouplist','member');???//獲取緩存中身份分組的列表 ????????if($this->isadmin==0?&&?!$grouplist[$this->groupid]['allowattachment'])?return?false;???//判斷是否允許上傳附件 ????????pc_base::load_sys_class('attachment','',0);???//加載attachment類 ????????$module?=?trim($_GET['module']);??//通過get方式獲取模型 ????????$catid?=?intval($_GET['catid']);??//通過get方式獲取catid ????????$siteid?=?$this->get_siteid();???//獲取站點ID ????????$site_setting?=?get_site_setting($siteid);???//獲取站點配置信息,這個函數在此模塊中的公共函數global.func.php中可以找到 ????????$site_allowext?=?$site_setting['upload_allowext'];??//獲取到允許的上傳文件類型? ????????$attachment?=?new?attachment($module,$catid,$siteid);???//實例化attachment類,就是上面剛剛提到的加載進來的類 ????????$attachment->set_userid($this->userid);??//調用attachment類的set_userid函數,確定是哪個用戶上傳的。 ????????$a?=?$attachment->upload('upload',$site_allowext);??//上傳文件,具體的函數請查看attachment類。 ????????if($a){?????//下面這些就是上傳成功后的一些路徑和文件名什么的了~ ????????????$filepath?=?$attachment->uploadedfiles[0]['filepath'];?$fn?=?intval($_GET['CKEditorFuncNum']);?$this->upload_json($a[0],$filepath,$attachment->uploadedfiles[0]['filename']);?$attachment->mkhtml($fn,$this->upload_url.$filepath,'');?}?}

以上應該解釋的比較詳細了,不懂的話可以自己看一下對應的文件,好了現在我們來看前端:


????????

這個就是上傳用的~注意調用的action的路徑就好了~再就是這里的的name屬性必須為upload否則無法上傳成功,因為在attachment類中定死了上傳的name屬性,所以 這里只能用這個了~

PHP中文網,大量的免費PHPCMS教程,歡迎在線學習!

立即學習PHP免費學習筆記(深入)”;

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊9 分享