php让图片可以下载的代码第1/2页

// 文件目录
define(‘DL_DIR', ‘temp/');
// 常见扩展名所对应的MIME类型
$MIMETypes = array(
‘ez' => ‘application/andrew-inset',
‘hqx' => ‘application/mac-binhex40′,
‘cpt' => ‘application/mac-compactpro',
‘doc' => ‘application/msword',
‘bin' => ‘application/octet-stream',
‘dms' => ‘application/octet-stream',
‘lha' => ‘application/octet-stream',
‘lzh' => ‘application/octet-stream',
‘exe' => ‘application/octet-stream',
‘class' => ‘application/octet-stream',
'so' => ‘application/octet-stream',
‘dll' => ‘application/octet-stream',
‘oda' => ‘application/oda',
‘pdf' => ‘application/pdf',
‘ai' => ‘application/postscrīpt',
‘eps' => ‘application/postscrīpt',
‘ps' => ‘application/postscrīpt',
'smi' => ‘application/smil',
'smil' => ‘application/smil',
‘mif' => ‘application/vnd.mif',
‘xls' => ‘application/vnd.ms-excel',
‘ppt' => ‘application/vnd.ms-powerpoint',
‘wbxml' => ‘application/vnd.wap.wbxml',
‘wmlc' => ‘application/vnd.wap.wmlc',
‘wmlsc' => ‘application/vnd.wap.wmlscrīptc',
‘bcpio' => ‘application/x-bcpio',
‘vcd' => ‘application/x-cdlink',
‘pgn' => ‘application/x-chess-pgn',
‘cpio' => ‘application/x-cpio',
‘csh' => ‘application/x-csh',
‘dcr' => ‘application/x-director',
‘dir' => ‘application/x-director',
‘dxr' => ‘application/x-director',
‘dvi' => ‘application/x-dvi',
'spl' => ‘application/x-futuresplash',
‘gtar' => ‘application/x-gtar',
‘hdf' => ‘application/x-hdf',
‘js' => ‘application/x-javascrīpt',
'skp' => ‘application/x-koan',
'skd' => ‘application/x-koan',
'skt' => ‘application/x-koan',
'skm' => ‘application/x-koan',
‘latex' => ‘application/x-latex',
‘nc' => ‘application/x-netcdf',
‘cdf' => ‘application/x-netcdf',
'sh' => ‘application/x-sh',
'shar' => ‘application/x-shar',
'swf' => ‘application/x-shockwave-flash',
'sit' => ‘application/x-stuffit',
'sv4cpio' => ‘application/x-sv4cpio',
'sv4crc' => ‘application/x-sv4crc',
‘tar' => ‘application/x-tar',
‘tcl' => ‘application/x-tcl',
‘tex' => ‘application/x-tex',
‘texinfo' => ‘application/x-texinfo',
‘texi' => ‘application/x-texinfo',
‘t' => ‘application/x-troff',
‘tr' => ‘application/x-troff',
‘roff' => ‘application/x-troff',
‘man' => ‘application/x-troff-man',
‘me' => ‘application/x-troff-me',
‘ms' => ‘application/x-troff-ms',
‘ustar' => ‘application/x-ustar',
'src' => ‘application/x-wais-source',
‘xhtml' => ‘application/xhtml+xml',
‘xht' => ‘application/xhtml+xml',
‘zip' => ‘application/zip',
‘au' => ‘audio/basic',
'snd' => ‘audio/basic',
‘mid' => ‘audio/midi',
‘midi' => ‘audio/midi',
‘kar' => ‘audio/midi',
‘mpga' => ‘audio/mpeg',
‘mp2′ => ‘audio/mpeg',
‘mp3′ => ‘audio/mpeg',
‘aif' => ‘audio/x-aiff',
‘aiff' => ‘audio/x-aiff',
‘aifc' => ‘audio/x-aiff',
‘m3u' => ‘audio/x-mpegurl',
‘ram' => ‘audio/x-pn-realaudio',
‘rm' => ‘audio/x-pn-realaudio',
‘rpm' => ‘audio/x-pn-realaudio-plugin',
‘ra' => ‘audio/x-realaudio',
‘wav' => ‘audio/x-wav',
‘pdb' => ‘chemical/x-pdb',
‘xyz' => ‘chemical/x-xyz',
‘bmp' => ‘image/bmp',
‘gif' => ‘image/gif',
‘ief' => ‘image/ief',
‘jpeg' => ‘image/jpeg',
‘jpg' => ‘image/jpeg',
‘jpe' => ‘image/jpeg',
‘png' => ‘image/png',
‘tiff' => ‘image/tiff',
‘tif' => ‘image/tiff',
‘djvu' => ‘image/vnd.djvu',
‘djv' => ‘image/vnd.djvu',
‘wbmp' => ‘image/vnd.wap.wbmp',
‘ras' => ‘image/x-cmu-raster',
‘pnm' => ‘image/x-portable-anymap',
‘pbm' => ‘image/x-portable-bitmap',
‘pgm' => ‘image/x-portable-graymap',
‘ppm' => ‘image/x-portable-pixmap',
‘rgb' => ‘image/x-rgb',
‘xbm' => ‘image/x-xbitmap',
‘xpm' => ‘image/x-xpixmap',
‘xwd' => ‘image/x-xwindowdump',
‘igs' => ‘model/iges',
‘iges' => ‘model/iges',
‘msh' => ‘model/mesh',
‘mesh' => ‘model/mesh',
'silo' => ‘model/mesh',
‘wrl' => ‘model/vrml',
‘vrml' => ‘model/vrml',
‘css' => ‘text/css',
‘html' => ‘text/html',
‘htm' => ‘text/html',
‘asc' => ‘text/plain',
‘txt' => ‘text/plain',
‘rtx' => ‘text/richtext',
‘rtf' => ‘text/rtf',
'sgml' => ‘text/sgml',
'sgm' => ‘text/sgml',
‘tsv' => ‘text/tab-separated-values',
‘wml' => ‘text/vnd.wap.wml',
‘wmls' => ‘text/vnd.wap.wmlscrīpt',
‘etx' => ‘text/x-setext',
‘xsl' => ‘text/xml',
‘xml' => ‘text/xml',
‘mpeg' => ‘video/mpeg',
‘mpg' => ‘video/mpeg',
‘mpe' => ‘video/mpeg',
‘qt' => ‘video/quicktime',
‘mov' => ‘video/quicktime',
‘mxu' => ‘video/vnd.mpegurl',
‘avi' => ‘video/x-msvideo',
‘movie' => ‘video/x-sgi-movie',
‘ice' => ‘x-conference/x-cooltalk',
);
?>

当前1/2页 12下一页阅读全文

(0)

相关推荐

  • php中使用gd库实现下载网页中所有图片

    在前期的php教程就讲了php gd库可以实现远程图片的下载,但是那只是下载了一张图片,原理是一样的,要想下载一个网页的所有图片只要使用正则表达式进行判断,找出所有的图片url就可以进行循环下载了,我特地参照网络资源编写了gd库图片下载类! php代码如下: <?php header("Content-type:text/html ; charset=utf-8"); if (!empty($_POST['submit'])){ $url = $_POST['url']; //为

  • PHP通过正则表达式下载图片到本地的实现代码

    复制代码 代码如下: <?php /* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/

  • 抓取并下载CSS中所有图片文件的php代码

    这篇文章的亮点是,正则式更加复杂鸟,╮(-_-)╭,再就是 Copy 函数的灰常强大的一个用法. > 话说刚才听 NsYta 说小邪的主题太白了,杯具.最近太忙,没有空,不然就自己搞一个新主题. 一. 抓取 CSS 中的图片: > 1. 首先做好准备工作: > 第一步,先把 CSS 原本的路径存到 $url 变量里,然后把 CSS 的内容保存在 abc.css 中. > 因为考虑到经常碰到多个 CSS 文件的状况,所以小邪没有直接填一个 CSS 路径. > 而是把几个 CSS

  • php中通过正则表达式下载内容中的远程图片的函数代码

    这段程序其实是属于"小偷程序"的重要部分. 这一段程序只是下载远程图片的那一段而已,程序写的比较简单,大多部分都做了注释. 复制代码 代码如下: if (preg_match_all("/http://[^ "']+[.jpg|.gif|.jpeg|.png]+/ui",stripcslashes($content),$aliurl)){ $i=0; //多个文件++ while(list($key ,$v) = each($aliurl[0])){ //

  • PHP批量采集下载美女图片的实现代码

    设计思路 考虑到单纯的采集一个网页的图片,太麻烦,所以直接采集他的列表页,获取列表的url然后在一一采集,但是用php匹配列表页的url太麻烦,第一列表页有很多无效url这对我这个正则小菜鸟实在是个问题,看了一下列表页的结构,果断采用jquery获取url,jquery的万能选择器又再次强大起来了. jquery获取url,然后ajax传递url->对应PHP文件,遍历url参数-->单页面采集保存图片 jquery程序 复制代码 代码如下: <script src="http

  • PHP实现图片批量打包下载功能

    上次遇到一个需要打包下载批量图片的问题,找了一下发现这个好方法,记录一下. 首先新建一个zipfile打包类: <?php class zipfile { var $datasec = array (); var $ctrl_dir = array (); var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; var $old_offset = 0; function unix2_dostime($unixtime = 0

  • PHP多线程批量采集下载美女图片的实现代码(续)

    个人认为影响的原因:匹配到的图片url并不是有效的url,文中只是简单的判断是否是相对路径,但是有些url是失效的 解决办法:就是新增判断是否是真实有效url的图片 复制代码 代码如下: /** *  *判断url是否有效  *@param $url string *@return boole  */function relUrl($url){ if(substr($url,0,4)=='http'){  $array = get_headers($url,true);  if(count($a

  • php实现改变图片直接打开为下载的方法

    本文实例讲述了php实现改变图片直接打开为下载的方法.分享给大家供大家参考.具体如下: process.php文件如下: $file = $_GET['file']; header("Content-type: octet/stream"); header("Content-disposition:attachment;filename=".$file.";"); header("Content-Length:".filesi

  • 使用ThinkPHP自带的Http类下载远程图片到本地的实现代码

    Http类在目录ThinkPHP/Lib/ORG/Net下面.接下来看看是如何调用的. 复制代码 代码如下: <?php import("Com.Buyback.QueryAmazon"); import("ORG.Net.Http"); class Image { public static function getImage($isbn) { $bookInformModel = D("bookinform"); $result = $

  • PHP使用pcntl_fork实现多进程下载图片的方法

    本文实例讲述了PHP使用pcntl_fork实现多进程下载图片的方法.分享给大家供大家参考.具体分析如下: PHP pcntl_fork - 在当前进程当前位置产生分支,子进程,译注:fork是创建了一个子进程,父进程和子进程 都从fork的位置开始向下继续执行,不同的是父进程执行过程中,得到的fork返回值为子进程号,而子进程得到的是0. 注意:PHP有个pcntl_fork的函数可以实现多进程,但要加载pcntl拓展,而且只有在linux下才能编译这个拓展. 1.首先在ubuntu下编译pc

随机推荐