【使用php下载的文件打不开,自己用着没问题,客户用就不行?】教程文章相关的互联网学习教程文章

phpheader函数文件下载时直接提示保存

$filename = '路径+实际文件名'; //文件的类型 header('Content-type: application/pdf'); //下载显示的名字 header('Content-Disposition: attachment; filename="保存时的文件名.pdf"'); readfile("$filename"); exit(); ?>以下是网上常用的方法 if (isset($link)) { Header("HTTP/1.1 303 See Other"); Header("Location: $link"); exit; }$link就是文件的实际路径。 附,服务器响应HTTP的类型ContentType大全: ".*"="a...

php多文件上传下载示例代码

php多文件上传下载示例代码 <html> <head><meta charset="utf-8"><title>index_uploads</title> </head> <body><form action="uploads.php" method="post" enctype="multipart/form-data"><input type="file" name="file[]"><br><input type="file" name="file[]"><br><input type="file" name="file[]"><br><input type="file" name="file[]"><br><input type="file" name="file[]"><br><input type="submit" value="uploads"></f...

php导出csv数据(浏览器中输出提供下载或保存到文件)

<?php/** * 导出数据到CSV文件 * @param array $data 数据 * @param array $title_arr 标题 * @param string $file_name CSV文件名 */function export_csv(&$data, $title_arr, $file_name = ) { ini_set("max_execution_time", "3600"); $csv_data = ; /** 标题 */ $nums = count($title_arr); for ($i = 0; $i < $nums - 1; ++$i) { $csv_data .= " . $title_arr[$i] . ",; } if ($nums > 0) { ...

php下载文件代码(兼容ie6浏览器)

<?php$filename = "./".$_REQUEST[name]; //具体路径,只要$filename是所要下载文件的完整路径即可if (!is_file($filename)) {//检测文件是否存在. die(下载的文件好像跟TM谁私奔啦!);}$filepath = str_replace(\\, /, realpath($filename));$filesize = filesize($filepath);$filename = substr(strrchr(/.$filepath, /), 1);$extension = strtolower(substr(strrchr($filepath, .), 1)); // use this unless you want to fi...

php下载远程图片函数示例(伪造来路)

/*** @功能:下载远程图片* @ bbs.it-home.org*/ function DownImageKeep($gurl, $rfurl, $filename, $gcookie="", $JumpCount=0, $maxtime=30) { $urlinfos = GetHostInfo($gurl); $ghost = trim($urlinfos['host']); if($ghost=='') { return FALSE; } $gquery = $urlinfos['query']; if($gcookie=="" && !empty($rfurl)) { $gcookie = RefurlCookie($rfurl); ...

php输出下载为桌面图标的例子

$Shortcut = "[InternetShortcut] URL=http://www.leduz.com/#shortcut IconFile=http://www.leduz.com/faviconbig.ico IconIndex=1 IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2 "; Header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=小桔灯分类信息网.url;"); echo $Shortcut; ?> 保存为php文件,点击链接后即可下载到桌面图标 注意,不同系统...

php抓取并下载css中所有图片文件

if (!is_dir(img)) { mkdir(img); }> 3、用正则式把图片相对地址取出来: if (preg_match(/^http.*/,$val)) { $target = $val; } else if (preg_match(/^\/.*/,$val)) { $target=$host.$val; } else { $target=$url.$val; } echo $target."\r\n";> 最后把文件名取出来,即 /img/1.gif 中的 1.gif,用于保存文件。 if (!is_file(./img/.$name[1])) { $imgc = file_get_contents($target); $handle = fopen(./img/.$name[1],w+); fwr...

phpcss文件背景图片下载器实现代码

/** *@阿唐 2013-4-6 22:19 *@呵呵 */ set_time_limit(0); error_reporting(E_ERROR); if($argcprint_r(' +-------------------------------------------------+ Usage: php '.$argv[0].' css路径类型(0为远程、1为本地) css文件路径 图片保存目录 Example: php.exe '.$argv[0].' 0 http://www.xxx.com/index.css \images\ +-------------------------------------------------+ '); exit...

php如何下载css文件中图片

//note 设置php超时时间 set_time_limit(0);//note 取得样式文件内容 $stylefilecontent = file_get_contents('images/style.css');//note 匹配出需要下载的url地址 preg_match_all("/url\((.*)\)/", $stylefilecontent, $imagesurlarray);//note 循环需要下载的地址,逐个下载 $imagesurlarray = array_unique($imagesurlarray[1]); foreach ($imagesurlarray as $imagesurl) { file_put_contents(basename($imagesurl), file_get...

php下载css文件中图片的实现代码

/* More & Original PHP Framwork Copyright (c) 2007 - 2008 IsMole Inc.Author: kimi Documentation: 下载样式文件中的图片,水水专用扒皮工具 *///note 设置PHP超时时间 set_time_limit(0);//note 取得样式文件内容 $styleFileContent = file_get_contents('images/style.css');//note 匹配出需要下载的URL地址 preg_match_all("/url\((.*)\)/", $styleFileContent, $imagesURLArray);//note 循环需要下载的地址,逐个下载 $ima...

php提取并下载css文件中图片地址

/** * 获取CSS中图片地址,并且保存到本地 */ class getInCssImage {/** * 图片保存下来 * @param $cssUrl css的url地址 * @param $dir 保存图片的目录 * @return void */ static public function saveImage($cssUrl, $dir) {$content = file_get_contents($cssUrl); $patterns = /images(.*).(jpg|gif|png)/; //正则根据不同地址需要变换 preg_match_all($patterns, $content, $matches); $imagesUrls = $matches[0]; i...

php函数(加密解密,随机字符串,截取字符串长度,强制下载等)

function encryptdecrypt($key, $string, $decrypt){ if($decrypt){ $decrypted = rtrim(mcrypt_decrypt(mcrypt_rijndael_256, md5($key), base64_decode($string), mcrypt_mode_cbc, md5(md5($key))), "12"); return $decrypted; }else{ $encrypted = base64_encode(mcrypt_encrypt(mcrypt_rijndael_256, md5($key), $string, mcrypt_mode_cbc, md5(md5($key)))); return $encrypted; ...

php怎么下载文件,php文件下载正确方法

// 检查 form 是否全部填写完毕...if ($form_completed) {Header("Location: http://www.myweb.com/download/info_check.exe");exit;}?>或者: 开始下载文件这里利用了ID方式接收要下载文件的编号,然后用“Redirect”的方式连接到实际的网址。 为安全起见,不让用户直接复制网址下载该文件,建议使用PHP直接读取该实际文件然后下载。 代码:$file_name = "info_check.exe";$file_dir = "/public/www/download/";if (!file_exists(...

php文件下载类代码,php文件下载处理类

/** 功 能: 文件下载*//*** 使用方法:$download = new Download();* //设置参数* $download->set_file_dir("c:/");* $download->set_file_name("boot.ini");* $download->set_read_bytes(1024);* //文件下载处理操作* $download->deal_with(); * //判断文件是否存在* if($download->is_file_exist()){*echo "file_exist";*}else{*echo "file_not_exist";*} */class Download {private $file = null;//文件句柄private $file_dir = ...

php怎么限制文件下载速度?php文件下载限速实例代码

php怎么控制文件下载速度,php编写的程序中实现文件下载,有时需要限速下载,其实用php header函数就可以控制文件下载速度,这里分享二个php实例代码,供大家参考。 一、php控制文件下载速度的方法。 代码:代码示例:二、php下载限制速度代码 php限制下载速度实现代码:代码示例: // local file that should be send to the client $local_file = test-file.zip; // filename that the user gets as default $download_file = your...