圖片傳真查看器下載 簡單的PHP圖片上傳程式

來源:互聯網
上載者:User
第一種:
php部分

複製代碼 代碼如下:


if($_FILES['file']['error'] > 0){
echo '!problem:';
switch($_FILES['file']['error'])
{
case 1: echo '檔案大小超過伺服器限制';
break;
case 2: echo '檔案太大!';
break;
case 3: echo '檔案只載入了一部分!';
break;
case 4: echo '檔案載入失敗!';
break;
}
exit;
}
if($_FILES['file']['size'] > 1000000){
echo '檔案過大!';
exit;
}
if($_FILES['file']['type']!='image/jpeg' && $_FILES['file']['type']!='image/gif'){
echo '檔案不是JPG或者GIF圖片!';
exit;
}
$today = date("YmdHis");
$filetype = $_FILES['file']['type'];
if($filetype == 'image/jpeg'){
$type = '.jpg';
}
if($filetype == 'image/gif'){
$type = '.gif';
}
$upfile = 'upfile/' . $today . $type;
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
if(!move_uploaded_file($_FILES['file']['tmp_name'], $upfile))
{
echo '移動檔案失敗!';
exit;
}
}
else
{
echo 'problem!';
exit;
}
echo '

success!


';
echo '檔案大小:' . $_FILES['file']['size'] . '位元組' . '
';
echo '檔案路徑:' . $upfile;
echo '' . '

';
$dirr = 'upfile/';
$dir = opendir($dirr);
echo $dirr . '--Listing:

    ';
    while($file = readdir($dir)){
    echo "
  • $file
  • ";
    }
    echo '
';
closedir($dir);
?>


第二種:

複製代碼 代碼如下:


if(empty($_GET[submit]))
{
?>

}else{
$path="uploadfiles/"; //上傳路徑
//echo $_FILES["filename"]["type"];
if(!file_exists($path))
{
//檢查是否有該檔案夾,如果沒有就建立,並給予最高許可權
mkdir("$path", 0700);
}//END IF
//允許上傳的檔案格式
$tp = array("image/gif","image/pjpeg","image/png");
//檢查上傳檔案是否在允許上傳的類型
if(!in_array($_FILES["filename"]["type"],$tp))
{
echo "格式不對";
exit;
}//END IF
if($_FILES["filename"]["name"])
{
$file1=$_FILES["filename"]["name"];
$file2 = $path.time().$file1;
$flag=1;
}//END IF
if($flag) $result=move_uploaded_file($_FILES["filename"]["tmp_name"],$file2);
//特別注意這裡傳遞給move_uploaded_file的第一個參數為上傳到伺服器上的臨時檔案
if($result)
{
//echo "上傳成功!".$file2;
echo "";
}//END IF
}
?>

以上就介紹了圖片傳真查看器下載 簡單的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.