<?php
if(is_uploaded_file($_FILES['file']['tmp_name'])){
$file='upload/'.basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $file)){
if($_FILES['file']['type']=='image/png' || $_FILES['file']['type']=='image/jpeg'){
if($_FILES['file']['size'] <2000000){//小於2MB時
echo $_FILES['file']['tmp_name'];
echo '<br>';
echo $_FILES['file']['name'];//檔案名稱
echo '<br>';
echo $_FILES['file']['size'], ' byte';
echo '<br>';
echo $file, '上傳成功。';
echo '<p><img src="',$file,'"></p>';
}else{
echo '此圖片不可超過2M';
}
}else{//如果不為圖檔的話
echo '此副檔名需為jpg.jpge.png';
}
}else{
echo '上傳失敗。';
}
}else{
echo '請選擇檔案。';
}
?>