php圖片檔案上傳執行個體代碼_PHP教程

來源:互聯網
上載者:User
提供一款簡單實用的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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.