新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名-創(chuàng)新互聯(lián)
怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

具體實(shí)現(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ù)暫無(wú)文檔
$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 "文件打開失敗,或者指定的不是圖像文件"; //輸出錯(cuò)誤信息
}看完上述內(nèi)容,你們掌握怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
分享標(biāo)題:怎么在php中利用圖片處理函數(shù)獲取文件的擴(kuò)展名-創(chuàng)新互聯(lián)
URL鏈接:http://fisionsoft.com.cn/article/hisjg.html


咨詢
建站咨詢
