php:通過多個文件格式顯示圖像
$ filename = basename($ file); $ file_extension = strtolower(substr(strrchr($ filename,“。”),1)); switch($ file_extension){ 案例“ gif”: $ ctype =“ image/gif”; 休息; 案例“ PNG”: $ ctype =“ image/png”; 休息; 案例“ jpeg”: 案例“ JPG”: $ ctype =“ image/jpeg”; 休息; 案例“ SVG”: $ ctype =“ image/svg xml”; 休息; 預設: } header('content-type:'。$ ctype); 此方法檢查文件擴展名並相應地設置內容類型。請注意,JPG文件的正確內容類型是“ Image/jpeg”。通過採用此方法,您可以確保正確顯示圖像的格式。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3