PHPCMS其实有一个叫做附件的模块,上传用的就是这个东西,现在我们来看一下对应的文件:phpcms\modules\attachment \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,'');
}
}

以上应该解释的比较详细了,不懂的话可以自己看一下对应的文件,好了现在我们来看前端:

<form method="post" enctype="multipart/form-data" action="/index.php?m=attachment&c=attachments&a=upload" id="uploadload" target="iframelogo">
<input type="file" class="uploadtxt" name="upload" /><input type="submit" value="dianji" />
</form>

这个就是上传用的~注意调用的action的路径就好了~再就是这里的<input type=file name="upload">的name属性必须为upload否则无法上传成功,因为在attachment类中定死了上传的name属性,所以 这里只能用这个了~

转载:http://www.cnblogs.com/woshikay/p/4329912.html

phpcms前端页面上传文件的更多相关文章

  1. 前端js上传文件 到后端接收文件

    下面是前端js代码: <html> <head> <meta http-equiv="Content-Type" content="text ...

  2. ASP.NET页面上传文件时提示文件大小超过请求解决方法

    在webconfig中节点 <system.web> </system.web> 下加入以下代码:maxRequestLength为限制上传文件大小,executionTime ...

  3. asp.net 页面上传文件控件后台代码Request.Files获取不到

    今天开发中遇到页面文件上传控件选择了文件,而后台Request.Files.Count取值为0,之前开发中遇到过几次,老是忘掉,今天记下来. html: <input type="fi ...

  4. 前端js上传文件后端C#接收文件

    本文粗略的讲下前端文件上传和后端文件接收的原理 前端代码 html <form onsubmit="uploadFile(event)"> <input type ...

  5. 前端js上传文件插件

    1. plupload文件上传 2.ajaxfileupload文件上传

  6. UI自动化页面需要选择上传文件

    UI自动化页面上传文件,百度查的时候说有4中方法,简便的方法是安装SendKeys,但是百度说这个只支持python2.7的 我的python版本是3.7的,目前还只碰到了非<input typ ...

  7. 基于Flask开发网站 -- 前端Ajax异步上传文件到后台

    大家好,我是辰哥~ 辰哥最近利用空闲时间在写一个在线可视化平台,过程中也觉得一些技术还是比较有意思的,所以就以模块化的形式分享出来.如:从网页界面(前端)上传文件到服务器(后端). 放一下该模块的界面 ...

  8. springboot(十七):使用Spring Boot上传文件

    上传文件是互联网中常常应用的场景之一,最典型的情况就是上传头像等,今天就带着带着大家做一个Spring Boot上传文件的小案例. 1.pom包配置 我们使用Spring Boot最新版本1.5.9. ...

  9. (转)Spring Boot(十七):使用 Spring Boot 上传文件

    http://www.ityouknow.com/springboot/2018/01/12/spring-boot-upload-file.html 上传文件是互联网中常常应用的场景之一,最典型的情 ...

随机推荐

  1. android判断当前应用程序处于前台还是后台

    /**     *判断当前应用程序处于前台还是后台     *      * @param context * @return         */    public static boolean ...

  2. android131 360 01 闪屏页和主页面

    主界面: 软件升级流程: 清单文件: <?xml version="1.0" encoding="utf-8"?> <manifest xml ...

  3. swfupload详细参数

    SWFUpload的初始化与配置 首先,在页面中引用SWFUpload.js ,如<script type=”text/javascript” src=”http://www.swfupload ...

  4. mysql聚合函数

    1.统计一下插入的数据总数 SELECT COUNT(giftCertificateId) AS number FROM gift_certificate WHERE giftCertificateN ...

  5. eclipse安装插件的方法,以python为例子

    一 转载自:http://www.cnblogs.com/linzhenjie/articles/2639113.html 1.基本需求 1.Eclipse 集成开发环境下载 http://115.c ...

  6. 从Eclipse里导出Android程序到手机里

    参考自:http://wenku.baidu.com/view/e28bb57c1711cc7931b716a7.html

  7. 区块上的三角形状的css写法

    .navbar .navline > .dropdown > .dropdown-menu:before { content: ''; display: inline-block; bor ...

  8. Tomcat启动报错 Failed to start component [StandardServer[8005]]解决

    SEVERE: The required Server component failed to start so Tomcat is unable to start. org.apache.catal ...

  9. xml读取

    select isnull(CamSeqId, '') as CamSeqId,isnull(cam_config.value('(xml/cam/StardardValue)[1]','int'), ...

  10. httperf ---linux web站点压力测试

    一.工具下载&&安装 软件获取 ftp://ftp.hpl.hp.com/pub/httperf/ 这里使用的是如下的版本 ftp://ftp.hpl.hp.com/pub/httpe ...