視頻php
session_start();
include "conn/conn.php";
//判斷檔案尾碼
//$f_type:允許檔案的尾碼類型
//$f_upfiles:上傳檔案名稱
function f_postfix($f_type,$f_upfiles){
$is_pass = false;
$tmp_upfiles = split(".",$f_upfiles);
$tmp_num = count($tmp_upfiles);
for($num = 0; $num < count($f_type);$num++){
if(strtolower($tmp_upfiles[$tmp_num - 1]) == $f_type[$num])
$is_pass = $f_type[$num];
}
return $is_pass;
}
$p_type = array("jpg","jpeg","bmp","gif","png");
$f_type = array("avi","rm","rmvb","wav","mp3","mpg");
$video_path = "upfiles/video";
$picture_path =" ";
$file_path = "";
/* 判斷上傳圖片類型和檔案大小,上傳圖片 */
if($_FILES[tb_video_picture][size] > 0 and $_FILES[tb_video_picture][size] < 700000){
if(($postf = f_postfix($p_type,$_FILES[tb_video_picture][name])) != false){
$picture_path = time().".".$postf;
$tb_video_picture=$video_path."/".$picture_path;
if($_FILES[tb_video_picture][tmp_name])
move_uploaded_file($_FILES[tb_video_picture][tmp_name],$video_path."\".$picture_path);
else{
echo "alert('上傳圖片失敗!');history.go(-1);";
exit();
}
}else{
echo "alert('上傳圖片格式錯誤!');history.go(-1);";
exit();
}
}else if($_FILES[tb_video_picture][size] > 700000){
echo "alert('上傳圖片大小超出範圍!');history.go(-1);";
exit();
}else{
$picture = "";
}
/******************************//* 判斷上傳檔案類型與大小,上傳檔案 */if($_FILES[tb_video_address][size] > 0){ //如果是音頻檔案 if($_FILES[tb_video_address][size] < 700000000000000000000){ if(($postf = f_postfix($f_type,$_FILES[tb_video_address][name])) != false){ $file_path = time().".".$postf;$tb_video_address=$video_path."/".$file_path; if($_FILES[tb_video_address][tmp_name]) move_uploaded_file($_FILES[tb_video_address][tmp_name],$video_path."\\".$file_path); else{ echo ""; exit(); } }else{ echo ""; exit(); } }else{ echo ""; exit(); }}/*else{ echo ""; exit();}*//****************//* 相同的資訊 */$tb_video_name = $_POST[tb_video_name]; //視頻名稱$tb_video_type = $_POST[tb_video_type]; $tb_video_explain = $_POST[tb_video_explain];$tb_video_author = $_POST[tb_video_author];$tb_video_date = date("Y-m-d H:i:s");/*****************/ $a_sqlstr = "insert into tb_video (tb_video_name,tb_video_picture,tb_video_type,tb_video_address,tb_video_author,tb_video_date,tb_video_explain,tb_video_auditing) values('$tb_video_name','$tb_video_picture','$tb_video_type','$tb_video_address','$tb_video_author','$tb_video_date','$tb_video_explain','0')";/***************************/$a_rst = $conn->execute($a_sqlstr);if(!($a_rst == false)){
$b_sqlstr="select * from tb_up_video where tb_video_user='$tb_video_author'";
$b_rst=$conn->execute($b_sqlstr);
$arrays=$b_rst->GetRows();
if(count($arrays)<=0){
$b1_sqlstr="insert into tb_up_video (tb_video_user,tb_up_counts)values('$tb_video_author','1')";
$b1_rst=$conn->execute($b1_sqlstr);
}else{
$b2_sqlstr="update tb_up_video set tb_up_counts=tb_up_counts+1 where tb_video_user='$tb_video_author'";
$b2_rst=$conn->execute($b2_sqlstr);
}
echo "";
include_once("subscibe.php");
exit();
}else{
echo "alert('添加失敗');history.go(-1);";
exit();
}
?>