提供一款簡單實用的php圖片檔案上傳執行個體代碼
php教程圖片檔案上傳執行個體代碼
php教程圖片檔案上傳執行個體代碼
if( $_post )
{
if( $_files['file'] )
{
$filename = $_files['file']['type'];
$newname ='php100.com.gif';
if( strtolower( $filename) == 'image/gif' )
{
if( move_uploaded_file($_files['file']['tmp_name'] ,$newname) )
{
//$ext = getimagesize( $newname );
//print_r($ext);
echo '圖片上傳成功';
}
else
{
die('圖片上傳失敗!');
}
}
else
{
exit('本程式只允許上傳gif圖片');
}
}
}
/*
move_uploaded_file 文法參考地址
http://www.bkjia.com/phper/24/da78cda75379943ff126f6af13cf5aa9.htm
strtolower執行個體地址
http://www.bkjia.com/phper/21/805cd7d41d20a10b71b35e1a8f2b8596.htm
$_files 說有
$_files[''myfile''][''name''] 用戶端檔案的原名稱。
$_files[''myfile''][''type''] 檔案的 mime 類型,需要瀏覽器提供該資訊的支援,例如"image/gif"。
$_files[''myfile''][''size''] 已上傳檔案的大小,單位為位元組。
$_files[''myfile''][''tmp_name''] 檔案被上傳後在服務端儲存的臨時檔案名稱,一般是系統預設。可以在php.ini的upload_tmp_dir 指定,但 用 putenv() 函數設定是不起作用的。
$_files[''myfile''][''error''] 和該檔案上傳相關的錯誤碼。[''error''] 是在 php 4.2.0 版本中增加的
*/
?>
本站原創教程轉載註明來源的於http://www.bkjia.com/phper/php.html
http://www.bkjia.com/PHPjc/444913.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444913.htmlTechArticle提供一款簡單實用的php圖片檔案上傳執行個體代碼 php教程圖片檔案上傳執行個體代碼 html xmlns=http://www.bkjia.com/1999/xhtml head meta http-equiv=content-type con...