zoukankan      html  css  js  c++  java
  • php读取url连接的图片,输出到浏览器

     header('Content-Type: application/pdf'); // PDF文件
                $fp = fopen($ret->url, "rb"); //二进制方式打开文件
                    fpassthru($fp); // 输出至浏览器
                    exit;

    如果是图片,就修改header头

    header('Content-Type: text/html; charset=utf-8'); //网页编码
    15 header('Content-Type: text/plain'); //纯文本格式
    16 header('Content-Type: image/jpeg'); //JPG、JPEG 
    17 header('Content-Type: application/zip'); // ZIP文件
    18 header('Content-Type: application/pdf'); // PDF文件
    19 header('Content-Type: audio/mpeg'); // 音频文件 
    20 header('Content-type: text/css'); //css文件
    21 header('Content-type: text/javascript'); //js文件
    22 header('Content-type: application/json'); //json
    23 header('Content-type: application/pdf'); //pdf
    24 header('Content-type: text/xml'); //xml
    25 header('Content-Type: application/x-shockw**e-flash'); //Flash动画

    fopen打开文件后得到不是字符串,不能直接输出要fgets()这个函数获取字符串,fgets()函数是从文件指针中读取一行。文件指针必须是有效的,必须指向由 fopen() 或 fsockopen() 成功打开的文件(并还未由 fclose() 关闭)。

    file_get_contents()打开网页后,返回的是一个字符串,可以直接输出的。

  • 相关阅读:
    vue 多层级嵌套组件传值 provide 和 inject
    vue 消息订阅与发布 实现任意组件间的通信
    成功
    疯掉的拼接
    解析发送
    一条条发
    com发送
    字符串拼接
    COM
    笨方法的combox级联
  • 原文地址:https://www.cnblogs.com/hanshuai0921/p/7416851.html
Copyright © 2011-2022 走看看