新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名-創(chuàng)新互聯(lián)
怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
具體實現(xiàn)代碼如下:
image_type=image_type_to_mime_type(imagetype_png); //獲取png的mime類型 echo $image_type; //輸出結(jié)果 // $file = '1.jpg'; $image = imagecreatefromjpeg($file); header('content-type: ' . image_type_to_mime_type(imagetype_wbmp)); $fp=fopen($file,r); fpassthru($fp); image2wbmp($image,"1.bmp"); // output the stream directly //image_type_to_extension. (php教程 5). image_type_to_extension — 取得圖像類型的文件 后綴 ... warning. 本函數(shù)暫無文檔 $file_ext=image_type_to_extension("1.jpg"); echo $file_ext; // $filename="1.jpg"; //定義圖像文件 $size=getimagesize($filename); //獲取圖像的大小 $fp=fopen($filename,"rb"); //打開文件 if($size && $fp) //如果成功打開 { header("content-type: {$size['mime']}"); //輸出文件頭信息 fpassthru($fp); //輸出文件內(nèi)容 exit; //中止操作 } else { echo "文件打開失敗,或者指定的不是圖像文件"; //輸出錯誤信息 }
看完上述內(nèi)容,你們掌握怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
當(dāng)前題目:怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://fisionsoft.com.cn/article/hisjg.html