12.
java上傳及影片播放
一、 select選單切換
-
先製作選項
$sql = "select `sn`,`name` from `".$xoopsDB->prefix("contact")."` ";
$result = $xoopsDB->query($sql);
$option="";
while(list($sn,$name)=$xoopsDB->fetchRow($result)){
$selected=($sn==$_GET['sn'])?"selected":"";
$option.="<option value='$sn' $selected>$name</option>";
}
-
然後加入切換選單
<select onChange=\"location.href='data.php?op={$_GET['op']}&sn='+this.value\">$option
</select>
-
新增jupload.php頁面,獨立一個頁面比較不會出問題。
<?php
include_once "header.php";
include_once XOOPS_ROOT_PATH."/modules/tadtools/jupload/jupload.php";
if(!$xoopsUser) die('無上傳權限');
if($_GET['op']=='import'){
if ($dh = opendir(XOOPS_ROOT_PATH."/uploads/contact/video")) {
while (($file = readdir($dh)) !== false) {
if(strlen($file)<=2)continue;
$f=explode(".",$file);
$ext=strtolower($f[1]);
rename(XOOPS_ROOT_PATH."/uploads/contact/video/{$file}",XOOPS_ROOT_PATH."/uploads/contact/{$_GET['sn']}.{$ext}");
die("請點擊「影片」以觀看之");
}
}
}else{
$appletParameters = array(
'maxFileSize' => '2G',
'postURL' => XOOPS_URL.'/modules/contact/jupload.php',
'archive' => XOOPS_URL.'/modules/tadtools/jupload/wjhk.jupload.jar',
'afterUploadURL' => XOOPS_URL."/modules/contact/index.php?sn={$_GET['sn']}&op=import",
'allowedFileExtensions' => 'flv/mp4',
'sendMD5Sum' => 'true',
'showLogWindow' => 'false',
'debugLevel' => 99
);
$classParameters = array(
'demo_mode' => false,
'allow_subdirs' => true,
'destdir' => XOOPS_ROOT_PATH."/uploads/contact/video"
);
$juploadPhpSupportClass = new JUpload($appletParameters, $classParameters);
echo "<!--JUPLOAD_APPLET-->";
}
?>
-
新增play.php頁面,檔名部份一律規範為「編號.mp4」格式(比較簡易)。
<?php
include_once "header.php";
include_once XOOPS_ROOT_PATH."/modules/tadtools/jwplayer.php";
$jw=new JwPlayer("play" , XOOPS_URL."/uploads/contact/{$_GET['sn']}.mp4" , $image , $width , $height , $skin , $mode , $display , $backcolor , $frontcolor , $lightcolor , $screencolor);
$player=$jw->render();
echo $player;
?>
-
請安裝firefox,接著安裝附加元件「DownloadHelper」即可下載各式影片檔。