uploadify上传视频无法保存到数据表里的问题

mikeccn mikeccn 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
求教:这样子视频文件是可以上传到\Uploads\Picture\目录了,但是video这个字段怎么存不到数据库里呢?
想跟踪,但是不知道要在哪里设置跟踪代码,数据写入代码在哪里呢?请不吝赐教!


<div class="form-item">
<label class="item-label">视频</label>
<div class="controls">
<input type="file" id="upload_video">
<input type="hidden" name="video" id="vid" value="{$people.video}"/>
<div class="upload-video-box">
<notempty name="people.video">
<div class="upload-pre-item">
<video width="602px" height="345px" controls="controls">
<source src="__ROOT__/{$people.video}" type="video/mp4"></source>
</video>
</div>
</notempty>
</div>
</div>
</div>



//上传视频
/* 初始化上传插件 */
$("#upload_video").uploadify({
"height" : 400,
"swf" : "__STATIC__/uploadify/uploadify.swf",
"fileObjName" : "download",
"buttonText" : "上传视频",
"uploader" : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
"width" : 600,
'removeTimeout' : 1,
'fileTypeExts' : '*.avi; *.rmvb; *.rm; *.asf; *.divx; *.mpg; *.mpeg; *.mpe; *.wmv; *.mp4; *.mkv; *.vob; *.gif;',
'fileSizeLimit' : '1024M',
"onUploadSuccess" : uploadVideoFrontvideo,
'onFallback' : function() {
alert('未检测到兼容版本的Flash.');
},
'onUploadSuccess' : function(file, data, response) {
//alert(file.name + ' | ' + response + ':' + data);
},
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
}
});
function uploadVideoFrontvideo(file, data){
var data = $.parseJSON(data);
var src = '';
if(data.status){
$("#vid").val(data.path);
src = data.url || '__ROOT__' + data.path
$("#vid").parent().find('.upload-video-box').html(
'<div class="upload-pre-item"><video width="602px" height="345px" controls="controls"><source src="' + src + '" type="video/mp4"></source></video></div>'
);
} else {
updateAlert(data.info);
setTimeout(function(){
$('#top-alert').find('button').click();
$(that).removeMatch_type('disabled').prop('disabled',false);
},1500);
}
}



use Think\Upload;
...
//====================================富文本框===========================

/* 上传图片 */
public function upload() {
/* 上传配置 */
$setting = C ( 'EDITOR_UPLOAD' );
$setting ['callback'] = array (
$this
);

/* 调用文件上传组件上传文件 */
$this->uploader = new Upload ( $setting, 'Local' );
$info = $this->uploader->upload ( $_FILES );
// dump($info);
if ($info) {
$dao = D ( 'Picture', 'Home' );
foreach ( $info as &$file ) {
$file ['rootpath'] = __ROOT__ . ltrim ( $setting ['rootPath'], "." );

/* 已经存在文件记录 */
if (isset ( $file ['id'] ) && is_numeric ( $file ['id'] )) {
$file ['path'] = __ROOT__ . ltrim ( $file ['path'], "." );
continue;
}

/* 记录文件信息 */
$file ['path'] = __ROOT__ . ltrim ( $setting ['rootPath'], "." ) . $file ['savepath'] . $file ['savename'];
$file ['status'] = 1;
$file ['create_time'] = NOW_TIME;
if ($dao->create ( $file ) && ($id = $dao->add ())) {
$file ['id'] = $id;
}
}
}

return $info;
}

// keditor编辑器上传图片处理
public function ke_upimg() {
/* 返回标准数据 */
$return = array (
'error' => 0,
'info' => '上传成功',
'data' => ''
);
$info = $this->upload();
$img = $info ['imgFile'] ['path'];
/* 记录附件信息 */
if ($img) {
$return ['id'] = $info ['imgFile'] ['id'];
$return ['url'] = $img;
unset ( $return ['info'], $return ['data'] );
} else {
$return ['error'] = 1;
$return ['message'] = $this->uploader->getError ();
}

/* 返回JSON数据 */

exit ( json_encode ( $return ) );
}

/* 上传视频 */
public function upload_v() {
// 上传配置
$setting = C ( 'EDITOR_UPLOAD' );
$setting ['callback'] = array (
$this
);

// 调用文件上传组件上传文件
$this->uploader = new Upload ( $setting, 'Local' );
$info = $this->uploader->upload ( $_FILES );
dump($info);
if ($info) {
$dao = D ( 'Picture', 'Home' );
foreach ( $info as &$file ) {
$file ['rootpath'] = __ROOT__ . ltrim ( $setting ['rootPath'], "." );

// 已经存在文件记录
if (isset ( $file ['id'] ) && is_numeric ( $file ['id'] )) {
$file ['path'] = __ROOT__ . ltrim ( $file ['path'], "." );
continue;
}

// 记录文件信息
$file ['path'] = __ROOT__ . ltrim ( $setting ['rootPath'], "." ) . $file ['savepath'] . $file ['savename'];
$file ['status'] = 1;
$file ['create_time'] = NOW_TIME;
if ($dao->create ( $file ) && ($id = $dao->add ())) {
$file ['id'] = $id;
}
}
}

return $info;
}

// keditor编辑器上传视频处理
public function ke_upvideo() { // 没用到
/* 返回标准数据 */
$return = array (
'error' => 0,
'info' => '上传成功',
'data' => ''
);
$info = $this->upload_v();
$video = $info ['videoFile'] ['path'];
/* 记录附件信息 */
if ($video) {
$return ['id'] = $info ['videoFile'] ['id'];
$return ['url'] = $video;
unset ( $return ['info'], $return ['data'] );
} else {
$return ['error'] = 1;
$return ['message'] = $this->uploader->getError ();
}

/* 返回JSON数据 */
exit ( json_encode ( $return ) );
}
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
mikeccn
基础编程 21,889 成员 140,329 内容