php 檔案上傳程式(二款簡單檔案上傳程式)_PHP教程

來源:互聯網
上載者:User
php 檔案上傳程式(二款簡單檔案上傳程式)/*這二款檔案上傳程式是非常簡單的,很適合初學者的學習php時的檔案上傳執行個體教程哦。

php教程 檔案上傳程式(二款簡單檔案上傳程式)
/*
這二款檔案上傳程式是非常簡單的,很適合初學者的學習php時的檔案上傳執行個體教程哦。
*/

if(!$uploadaction):
?>



檔案上傳介面







else:
?>



檔案上傳代碼

$uploadaction=0;
echo "good!";
$timelimit=60; /*設定逾時限制時間 預設時間為30秒 設定為0時為不限時 */
set_time_limit($timelimit);

if(($uploadfile !="none" ))
{
$uploadpath=addslashes(dirname($path_translated))."upload"; //上傳檔案存放路徑

$filename=$uploadpath.$uploadfile_name; //上傳檔案名稱

if($uploadfile_size < 1024) //上傳檔案大小
{
$filesize=(string)$uploadfile_size." 位元組";
}
elseif ($uploadfile_size <(1024 * 1024))
{
$filesize=number_format((double)($uploadfile_size/1024), 1) . " kb";
}
else{
$filesize=number_format((double)($uploadfile_size / (1024 * 1024)), 1) . " mb";
}

if(!file_exists($filename))
{
if(copy($uploadfile,$filename))
{ echo "檔案 $uploadfile_name ($filesize)上傳成功!"; }
else
{ echo "檔案 $uploadfile_name上傳失敗!"; }

unlink($uploadfile);
}
else
{ echo "檔案 $uploadfile_name已經存在!"; }
}
else
{ echo "你沒有選擇任何檔案上傳!"; }

set_time_limit(30); //恢複預設逾時設定

?>


返回


endif;
?>

方法二



檔案上傳






















if(isset($submit)){ if($myfile != "none") { $upload_dir = "c:winnttemp"; $up=copy($myfile,$upload_dir); if($up==1) { print("檔案上傳成功!"); } else { print ("檔案上傳失敗."); } unlink ($myfile); } else { print("你沒有上傳任何檔案"); }} ?>



http://www.bkjia.com/PHPjc/444862.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444862.htmlTechArticlephp 檔案上傳程式(二款簡單檔案上傳程式)/*這二款檔案上傳程式是非常簡單的,很適合初學者的學習php時的檔案上傳執行個體教程哦。 php教程...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.