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