phpcms 上传视频,后台上传视频,以及前台调用。phpcms上传视频亲测可用。

57 篇文章 0 订阅
35 篇文章 0 订阅

       

1、后台设置:

【内容】->【模型管理】->找到视频模型打开【字段管理】->将字段名为video删除->添加字段->【字段类型】选择多文件上传->【字段名】填写video->【允许上传类型】填写mp4|flv|f4v|3gp|swf

 

 

2、修改后台上传附件大小限制

 

3、修改代码上传附件大小限制

\www\phpcms\modules\attachment\attachmen.php

ts.php

public function swfupload(){
		$grouplist = getcache('grouplist','member');
		$siteid = $this->get_siteid();
		if(isset($_GET['dosubmit'])){
			// if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();//暂时取消判断
			pc_base::load_sys_class('attachment','',0);
			$siteid = get_siteid();
			$attachment = new attachment($_POST['module'],$_POST['catid'],$siteid);
			$attachment->set_userid($this->userid);
			$site_setting = get_site_setting($siteid);
			$site_allowext = $site_setting['upload_allowext'];
			$aids = $attachment->upload('file',$site_allowext,'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
			if($aids[0]) {
				$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename'];
				if($attachment->uploadedfiles[0]['isimage']) {
					$res = array(
						'status' => 1,
						'aid' =>  $aids[0],
						'filepath' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
						'fileext' => $attachment->uploadedfiles[0]['fileext'],
						'isimage' => $attachment->uploadedfiles[0]['isimage'],
						'title'   => str_replace('.'.$attachment->uploadedfiles[0]['fileext'],'',$filename),
						'fileimg' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
						'filename' => $filename
					);
					echo json_encode($res);
				} else {
					$fileext = $attachment->uploadedfiles[0]['fileext'];
					if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar';
					elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc';
					elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls';
					elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt';
					elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv';
					else $fileext = 'do';
					$res = array(
						'status' => 1,
						'aid' =>  $aids[0],
						'filepath' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
						'fileext' => $fileext,
						'isimage' => $attachment->uploadedfiles[0]['isimage'],
						'title'   => str_replace('.'.$attachment->uploadedfiles[0]['fileext'],'',$filename),
						'fileimg' => file_icon($this->upload_url.$attachment->uploadedfiles[0]['filepath']),
						'filename' => $filename
					);
					echo json_encode($res);
				}			
				exit;
			} else {
				echo '0,'.$attachment->error();
				exit;
			}
		} else {
			if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission'));
			$args = $_GET['args'];
			$authkey = $_GET['authkey'];
			if(upload_key($args) != $authkey) showmessage(L('attachment_parameter_error'));
			extract(getswfinit($_GET['args']));
			$siteid = $this->get_siteid();
			$site_setting = get_site_setting($siteid);
			$file_size_limit = sizecount($site_setting['upload_maxsize']*10240);	
			$filetype = str_replace('|',',',$file_types_post);
			$att_not_used = param::get_cookie('att_json');
			if(empty($att_not_used) || !isset($att_not_used)) $tab_status = ' class="on"';
			if(!empty($att_not_used)) $div_status = ' hidden';
			//获取临时未处理文件列表
			$att = $this->att_not_used();
			$userid_flash=sys_auth($this->userid, 'ENCODE');
			// include $this->admin_tpl('swfupload');
			include $this->admin_tpl('webuploader');
		}
	}

 

 

 

4、页面调用视频

phpcms有个方法:string2array. 用来将数组字符串处理并返回为数组.

 

 

 

 

 

 

{pc:content action="lists" catid="17" moreinfo="1"  order="listorder desc, inputtime desc"}
                          {loop $data $v}
                             
                             <?php var_dump(string2array($v[video]));?>
                           {/loop}
                       
                            {/pc}

 

 

 

{pc:content action="lists" catid="17" moreinfo="1"  order="listorder desc, inputtime desc"}
                          {loop $data $v}
                              <div class="swiper-slide"><span class="paly-btn"></span><video  src="
 <?php echo string2array($v[video])[0][fileurl];?>" poster="{$v[thumb]}" ></video></div>
                           {/loop}
                       
                            {/pc}

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值