<<線上檔案上傳>>
include ("config.php");
function Fix_Backslash($org_str) {
/*
$tmp_length = strlen($org_str);
for ( $tmp_i=0; $tmp_i<$tmp_length; $tmp_i++ ) {
$ascii_str_a = substr($org_str, $tmp_i , 1);
$ascii_str_b = substr($org_str, $tmp_i+1, 1);
$ascii_value_a = ord($ascii_str_a);
$ascii_value_b = ord($ascii_str_b);
if ( $ascii_value_a > 127 ) {
if ( $ascii_value_b == 92 ) {
$org_str = substr($org_str, 0, $tmp_i+2) . substr($org_str,$tmp_i+3);
$tmp_length = strlen($org_str);
}
$tmp_i++;
}
}
$tmp_length = strlen($org_str);
if ( substr($org_str, ($tmp_length-1), 1) == "\\" ) $org_str .= chr(32);
$org_str = str_replace("\\0", "\ 0", $org_str);
*/
return $org_str;
}
if($act==NULL):
if( strtotime ($GLOBALS["UP_DATE"]) > strtotime ("now"))
{
?>
";
}
else
{
echo "目前已經過了上傳時間";
}
?>
|
線上檔案上傳
|
| 檔名 |
上傳者 |
學號 |
上傳時間 |
上傳者IP |
if(!($fpdir = @fopen($up_dir."/dir.log", "r")))
{
echo "記錄檔讀取失敗";
}
else
{
while ($file_data = fgets($fpdir,4096)):
$file_array = split (",", $file_data);
list ($file_id,$file_name, $name, $no, $ftime, $fip) = $file_array;
?>
|
";
}
echo "$file_name";
?>
|
|
|
|
|
endwhile;
fclose($fpdir);
}
endif;
?>
if($act=="上傳"):
if(empty($up_file_name))
{
echo "你沒有選擇要上傳的檔案呢!請按「瀏灠」選擇要上傳的檔案!";
}
else if(empty($up_name) || empty($up_no))
{
echo "名字和學號一定要輸入";
}
else
{
//$up_file = stripslashes($up_file);
$up_file_name =Fix_Backslash($up_file_name);
$up_name = Fix_Backslash($up_name);
//$up_file_name = $up_name."-".$up_no."-".$up_file_name;
$file_id = time(). strrchr($up_file_name,'.');
$dest=Fix_Backslash($up_dir."/".$file_id);
//檢查檔名是否有重覆
/*while(file_exists($dest))
{
// Last Dot Inde
$mintLastDotIndex = strrpos($up_file_name,".");
$up_file_name = substr_replace ($up_file_name,"-new",$mintLastDotIndex,0);
$dest="$up_dir/$up_file_name";
}*/
if(@copy($up_file,$dest))
{
if(!($fplog = @fopen($up_dir."/dir.log", "a")))
{
@unlink($up_dir."/dir.log");
echo "記錄檔存取失敗
";
}
else
{
//取得上傳檔案時間
$ftime = date("Y-m-d a h:i", filectime($up_file));
//取得使用者IP
if ( getenv( HTTP_X_FORWARDED_FOR ))
$gstrGUEST_IP = getenv( HTTP_X_FORWARDED_FOR ) ;
else
$gstrGUEST_IP = getenv( REMOTE_ADDR ) ;
fwrite($fplog, $file_id.",".$up_file_name.",".$up_name.",".$up_no.",".$ftime.",".$gstrGUEST_IP."\n");
echo "$up_file_name 已順利上傳!";
fclose($fplog);
}
}
else
{
echo "上傳失敗!";
}
}
echo "";
endif;
?>
Design By Tau
File Transmission Ver 1.4 s