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. 特殊用途语言特性——默认参数、内联函数和constexptr函数

    1 默认实参 某些函数有这样一些参数,在函数的很多次调用中它们都被赋予一个相同的值,此时,我们把这个反复出现的值称为函数的默认实参.调用含有默认实参的函数时,可以包含该实参,也可以省略该实参. 我们可 ...

  2. rem移动端适配

    rem作为一个低调的长度单位,由于手机端网页的兴起,在屏幕适配中得到重用.使用 rem 前端开发者可以很方便的在各种屏幕尺寸下,通过等比缩放的方式达到设计图要求的效果. rem 的官方定义『The f ...

  3. c/c++中动态内存分配处理字符串的细节问题

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h&g ...

  4. Android_ViewFlipper

    xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...

  5. PHP代码安全学习笔记V1.0

    PHP代码安全学习笔记V1.0http://www.docin.com/p-778369487.html

  6. Oracle Goldengate工作原理

  7. 深入理解计算机系统第二版习题解答CSAPP 2.19

    在2.17的基础上完成下表: x 十六进制 T2U(x) -8 0x8 -3 0xD -2 0xE -1 0xF 0 0x0 5 0x5

  8. 有关于Algorithm的基础介绍

    Niklaus Wirth:Algorithm + Data Structures = Programs 这句话呢,觉得很正确,算法和程序是不同的概念,算法的思想呢有递推,枚举,分治,贪婪,试探法,模 ...

  9. jquery easyui combobox 级联及触发事件,combobox级联

    jquery easyui combobox 级联及触发事件,combobox级联 >>>>>>>>>>>>>>&g ...

  10. 巧用selectKey

    在Ibatis中,insert()的返回值为一个Object的主键,其实这个Object的主键是这样的来的:如果在bean的xml文件中设置了插入的keyProperty,则insert()方法返回的 ...