一个不错php文件缓存类文件

 更新时间:2016年11月25日 16:21  点击:1654
本人给大家推一个不错php文件缓存类文件,从各方面来看本缓存类很合理并且适用于大型网站使用哦,有需要的朋友可参考参考。
 代码如下 复制代码

<?php
class Cache {
 /** 缓存目录 **/
 var $CacheDir        = './c';
 /** 缓存的文件 **/
 var $CacheFile        = '';
 /** 文件缓存时间(分钟) **/
 var $CacheTime        = 0;
 /** 文件是否已缓存 **/
 var $CacheFound        = False;
 /** 错误及调试信息 **/
 var $DebugMsg        = NULL;

 function Cache($CacheTime = 0) {
  $this->CacheTime    = $CacheTime;
 }

 private function Run() {
  /** 缓存时间大于0,检测缓存文件的修改时间,在缓存时间内为缓存文件名,超过缓存时间为False,
                小于等于0,返回false,并清理已缓存的文件
         **/
  Return $this->CacheTime ? $this->CheckCacheFile() : $this->CleanCacheFile();
 }
 function GetCache($VistUrl,$CacheFileType = 'html')
 {
  $this->SetCacheFile($VistUrl,$CacheFileType);

  $fileName=$this->CheckCacheFile();
  if($fileName)
  {
   $fp = fopen($fileName,"r");
   $content_= fread($fp, filesize($fileName));
   fclose($fp);
   return $content_;
  }
  else
  {
   return false;
  }
 }
 private function SetCacheFile($VistUrl,$CacheFileType = 'html') {
  if(empty($VistUrl)) {
   /** 默认为index.html **/
   $this->CacheFile = 'index';
  }else {
   /** 传递参数为$_POST时 **/
   $this->CacheFile = is_array($VistUrl) ? implode('.',$VistUrl) : $VistUrl;
  }
  $this->CacheFile = $this->CacheDir.'/'.md5($this->CacheFile);
  $this->CacheFile.= '.'.$CacheFileType;
 }

 function SetCacheTime($t = 60) {
  $this->CacheTime = $t;
 }

 private function CheckCacheFile() {
  if(!$this->CacheTime || !file_exists($this->CacheFile)) {Return False;}
  /** 比较文件的建立/修改日期和当前日期的时间差 **/
  $GetTime=(Time()-Filemtime($this->CacheFile))/(60*1);
  /** Filemtime函数有缓存,注意清理 **/
  Clearstatcache();
  $this->Debug('Time Limit '.($GetTime*60).'/'.($this->CacheTime*60).'');
  $this->CacheFound = $GetTime <= $this->CacheTime ? $this->CacheFile : False;
  Return $this->CacheFound;
 }

 function SaveToCacheFile($VistUrl,$Content,$CacheFileType = 'html') {
  $this->SetCacheFile($VistUrl,$CacheFileType);
  if(!$this->CacheTime) {
   Return False;
  }
  /** 检测缓存目录是否存在 **/
  if(true === $this->CheckCacheDir()) {
   $CacheFile = $this->CacheFile;
   $CacheFile = str_replace('//','/',$CacheFile);
   $fp = @fopen($CacheFile,"wb");
   if(!$fp) {
    $this->Debug('Open File '.$CacheFile.' Fail');
   }else {
    if(@!fwrite($fp,$Content)){
     $this->Debug('Write '.$CacheFile.' Fail');
    }else {
     $this->Debug('Cached File');
    };
    @fclose($fp);
   }
  }else {
   /** 缓存目录不存在,或不能建立目录 **/
   $this->Debug('Cache Folder '.$this->CacheDir.' Not Found');
  }
 }

 private function CheckCacheDir() {
  if(file_exists($this->CacheDir)) { Return true; }
  /** 保存当前工作目录 **/
  $Location = getcwd();
  /** 把路径划分成单个目录 **/
  $Dir = split("/", $this->CacheDir);
  /** 循环建立目录 **/
  $CatchErr = True;
  for ($i=0; $i<count($Dir); $i++){
   if (!file_exists($Dir[$i])){
    /** 建立目录失败会返回False 返回建立最后一个目录的返回值 **/
    $CatchErr = @mkdir($Dir[$i],0777);
   }
   @chdir($Dir[$i]);
  }
  /** 建立完成后要切换到原目录 **/
  chdir($Location);
  if(!$CatchErr) {
   $this->Debug('Create Folder '.$this->CacheDir.' Fail');
  }
  Return $CatchErr;
 }

 private function CleanCacheFile() {
  if(file_exists($this->CacheFile)) {
   @chmod($this->CacheFile,777);
   @unlink($this->CacheFile);
  }
  /** 置没有缓存文件 **/
  $this->CacheFound = False;
  Return $this->CacheFound;
 }

 function Debug($msg='') {
  if(DEBUG) {
   $this->DebugMsg[] = '[Cache]'.$msg;
  }
 }

 function GetError() {
  Return empty($this->DebugMsg) ? '' : "<br>n".implode("<br>n",$this->DebugMsg);
 }
}/* end of class */


?>

小偷程序其实就是利用了php中的一特定函数实现采集别人网站的内容,然后通过正则分析把我们想要的内容保存到自己本地数据库了,下面我来介绍php小偷程序的实现方法,有需要的朋友可参考。

在下面采集数据过程中file_get_contents函数是关键了,下面我们来看看file_get_contents函数语法

string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
和 file() 一样,只除了 file_get_contents() 把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败, file_get_contents() 将返回 FALSE。

file_get_contents() 函数是用来将文件的内容读入到一个字符串中的首选方法。如果操作系统支持还会使用内存映射技术来增强性能。

 代码如下 复制代码

<?php
$homepage = file_get_contents('http://www.111cn.net/');
echo $homepage;
?>

这样$homepage就是我们采集网的内容给保存下来了,好了说了这么多我们开始吧。

 代码如下 复制代码

<?php

function fetch_urlpage_contents($url){
$c=file_get_contents($url);
return $c;
}
//获取匹配内容
function fetch_match_contents($begin,$end,$c)
{
$begin=change_match_string($begin);
$end=change_match_string($end);
$p = "{$begin}(.*){$end}";
if(eregi($p,$c,$rs))
{
return $rs[1];}
else { return "";}
}//转义正则表达式字符串
function change_match_string($str){
//注意,以下只是简单转义
//$old=array("/","$");
//$new=array("/","$");
$str=str_replace($old,$new,$str);
return $str;
}

//采集网页
function pick($url,$ft,$th)
{
$c=fetch_urlpage_contents($url);
foreach($ft as $key => $value)
{
$rs[$key]=fetch_match_contents($value["begin"],$value["end"],$c);
if(is_array($th[$key]))
{ foreach($th[$key] as $old => $new)
{
$rs[$key]=str_replace($old,$new,$rs[$key]);
}
}
}
return $rs;
}

$url="http://www.111cn.net"; //要采集的地址
$ft["title"]["begin"]="<title>"; //截取的开始点
$ft["title"]["end"]="</title>"; //截取的结束点
$th["title"]["中山"]="广东"; //截取部分的替换

$ft["body"]["begin"]="<body>"; //截取的开始点
$ft["body"]["end"]="</body>"; //截取的结束点
$th["body"]["中山"]="广东"; //截取部分的替换

$rs=pick($url,$ft,$th); //开始采集

echo $rs["title"];
echo $rs["body"]; //输出
?>

以下代码从上一面修改而来,专门用于提取网页所有超链接,邮箱或其他特定内容

 代码如下 复制代码

<?php

function fetch_urlpage_contents($url){
$c=file_get_contents($url);
return $c;
}
//获取匹配内容
function fetch_match_contents($begin,$end,$c)
{
$begin=change_match_string($begin);
$end=change_match_string($end);
$p = "#{$begin}(.*){$end}#iU";//i表示忽略大小写,U禁止贪婪匹配
if(preg_match_all($p,$c,$rs))
{
return $rs;}
else { return "";}
}//转义正则表达式字符串
function change_match_string($str){
//注意,以下只是简单转义
$old=array("/","$",'?');
$new=array("/","$",'?');
$str=str_replace($old,$new,$str);
return $str;
}

//采集网页
function pick($url,$ft,$th)
{
$c=fetch_urlpage_contents($url);
foreach($ft as $key => $value)
{
$rs[$key]=fetch_match_contents($value["begin"],$value["end"],$c);
if(is_array($th[$key]))
{ foreach($th[$key] as $old => $new)
{
$rs[$key]=str_replace($old,$new,$rs[$key]);
}
}
}
return $rs;
}

$url="http://www.111cn.net"; //要采集的地址
$ft["a"]["begin"]='<a'; //截取的开始点<br />
$ft["a"]["end"]='>'; //截取的结束点

$rs=pick($url,$ft,$th); //开始采集

print_r($rs["a"]);

?>

小提示file_get_contents很是容易被防采集了,我们可以使用curl来模仿用户对网站进行访问,这算比上面要高级不少哦,file_get_contents()效率稍低些,常用失败的情况、curl()效率挺高的,支持多线程,不过需要开启下curl扩展。下面是curl扩展开启的步骤:

1、将PHP文件夹下的三个文件php_curl.dll,libeay32.dll,ssleay32.dll复制到system32下;

2、将php.ini(c:WINDOWS目录下)中的;extension=php_curl.dll中的分号去掉;

3、重启apache或者IIS。

简单的抓取页面函数,附带伪造 Referer 和 User_Agent 功能

 代码如下 复制代码

<?php
function GetSources($Url,$User_Agent='',$Referer_Url='') //抓取某个指定的页面
{
//$Url 需要抓取的页面地址
//$User_Agent 需要返回的user_agent信息 如“baiduspider”或“googlebot”
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $Url);
curl_setopt ($ch, CURLOPT_USERAGENT, $User_Agent);
curl_setopt ($ch, CURLOPT_REFERER, $Referer_Url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$MySources = curl_exec ($ch);
curl_close($ch);
return $MySources;
}
$Url = "http://www.111cn.net"; //要获取内容的也没
$User_Agent = "baiduspider+(+http://www.baidu.com/search/spider.htm)";
$Referer_Url = 'http://www.111cn.net/';
echo GetSources($Url,$User_Agent,$Referer_Url);
?>

在php中我们也有可以直接来操作ftp,然后利用php实现与ftp一样的文件上传与下载文件的功能哦,下面我来介绍一个完整的实例。

一、LycFtpAbstract.class.php   FTP基类

 代码如下 复制代码
<?php
    /*  author:凹凸曼(lyc)
    /*  email: jar-c@163.com
    /*  time : 2011-04-22
    */
 
abstract class Lyc_Ftp_Abstract {
 
    protected $ftpobj=null;
    protected $host='';
    protected $user='anonymous';
    protected $pwd='';
    protected $mode=FTP_BINARY;
    protected $port=21;
    protected $timeout=90;
 
    protected $pasv=TRUE;
 
    protected function init(){
 
    }
    /**
    * 建立ftp连接
    *
    */
    protected function connect(){
       $this->ftpobj=@ftp_connect($this->host,$this->port,$this->timeout);
       if(null==$this->ftpobj){
        require_once 'Lyc/Ftp/Exception.class.php';
       throw new Lyc_Ftp_Exception("FTP ERROR : Couldn't connect to $this->host");
       }
    }
    /**
    * 建立ssl ftp连接
    *
    */
    protected function connectSsl(){
       $ftpobj=@ftp_ssl_connect($this->host,$this->port,$this->timeout);
       if(null==$ftpobj){
        require_once 'Lyc/Ftp/Exception.class.php';
       throw new Lyc_Ftp_Exception("FTP ERROR : Couldn't connect to $this->host");
       }
    }
    /**
    * 登录验证ftp 及设置模式
    *
    */
    protected function login(){
 
        if(@ftp_login($this->ftpobj,$this->user,$this->pwd)){
            ftp_pasv($this->ftpobj,$pasv);
 
        }else{
            require_once 'Lyc/Ftp/Exception.class.php';
            throw new Lyc_Ftp_Exception("FTP ERROR : Couldn't login to $this->host");
        }
    }
    /**
    * 上传文件
    *
    */
    public function upload($remotefile,$localfile){
 
    }
    /**
    * 下载文件
    *
    */
    public function download($localfile,$remotefile){
 
    }
    /**
    * 关闭连接
    *
    */
    public function close(){
        if(is_string($this->ftpobj)){
            ftp_close($this->ftpobj);
        }
    }
 
}
?>

 
 
二、LycFtpFtp.class.php   实现类

 代码如下 复制代码
 <?php
    /*  author:凹凸曼(lyc)
    /*  email: jar-c@163.com
    /*  time : 2011-04-22
    /*
    */
require_once 'Lyc/Ftp/Abstract.class.php';
class Lyc_Ftp_Ftp extends Lyc_Ftp_Abstract{
 
    public function __construct($host,$user,$pwd,$mode=FTP_BINARY,$port=21,$timeout=90,$pasv=TRUE){
        $this->host=$host;
        $this->user=$user;
        $this->pwd=$pwd;
        $this->mode=$mode;
        $this->port=$port;
        $this->timeout=$timeout;
        $this->pasv=$pasv;
        $this->init();
 
    }
    protected function init(){
 
            $this->connect();
            $this->login();
 
    }
    /**
    * 上传文件
    *
    */
    public function upload($remotefile,$localfile){
 
       $res=ftp_nb_put($this->ftpobj,$remotefile,$localfile,$this->mode,ftp_size($this->ftpobj,$remotefile));
       while($res==FTP_MOREDATA){
           $res=ftp_nb_continue($this->ftpobj);
       }
       if($res!=FTP_FINISHED){
           return FALSE;
       }
       return TRUE;
    }
    /**
    * 下载文件
    *
    */
    public function download($localfile,$remotefile){
        ftp_set_option($this->ftpobj,FTP_AUTOSEEK,FALSE);
        $res=ftp_nb_get($this->ftpobj,$localfile,$remotefile,$this->mode,ftp_size($this->ftpobj,$localfile));
        while($res==FTP_MOREDATA){
            $res=ftp_nb_continue($this->ftpobj);
        }
        if($res!=FTP_FINISHED){
            return FALSE;
        }
        return TRUE;
    }
}
?>

 
三、LycException.class.php  异常基类

 代码如下 复制代码
 <?php
    /*  author:凹凸曼(lyc)
    /*  email: jar-c@163.com
    /*  time : 2011-04-22
    /*  
 
    */
    class Lyc_Exception extends Exception{
 
    }
?>
 


四、LycFtpException.class.php  FTP异常类

 

 代码如下 复制代码
 <?php
    /*  author:凹凸曼(lyc)
    /*  email: jar-c@163.com
    /*  time : 2011-04-22
    */
require_once 'Lyc/Exception.class.php';
class Lyc_Ftp_Exception extends Lyc_Exception{
 
}
?>
 


五、测试区

 代码如下 复制代码


 <?php
   /**
    * 上传文件
    *
    */
    public  function uploadTest(){
        require_once 'Lyc/Ftp/Ftp.class.php';
        $host=23.64.41.13';     //主机
        $user='tguser';                //用户名
        $pwd="";                         //密码   端口默认21 也可改
        $ftp=new Lyc_Ftp_Ftp($host,$user,$pwd);
        $res=$ftp->upload('test.rar',"F:\wwwroot\testarea\Lyc\Test\test.rar");
        if(!$res){
            echo " upload failure";
        }
 
    }
 
    public function downloadTest(){
        require_once 'Lyc/Ftp/Ftp.class.php';
        $host=33.64.41.135';
        $user='tguser';
        $pwd="";
        $ftp=new Lyc_Ftp_Ftp($host,$user,$pwd);
        $res=$ftp->download("c:\test.rar","test.rar");
        if(!$res){
            echo "download failure";
        }
 
    }

fsockopen是php中一个比较实用的函数了,下面我来介绍利用fsockopen函数来采集网页的程序,有需要的朋友可参考。

用法
int fsockopen(string hostname, int port, int [errno], string [errstr], int [timeout]);

一个采集网页实例

 代码如下 复制代码

<?php
function get_url ($url,$cookie=false)
{
$url = parse_url($url);
$query = $url[path].”?”.$url[query];
echo “Query:”.$query;
$fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30);
if (!$fp) {
return false;
} else {
$request = “GET $query HTTP/1.1rn”;
$request .= “Host: $url[host]rn”;
$request .= “Connection: Closern”;
if($cookie) $request.=”Cookie:   $cookien”;
$request.=”rn”;
fwrite($fp,$request);
while(!@feof($fp)) {
$result .= @fgets($fp, 1024);
}
fclose($fp);
return $result;
}
}
//获取url的html部分,去掉header
function GetUrlHTML($url,$cookie=false)
{
$rowdata = get_url($url,$cookie);
if($rowdata)
{
$body= stristr($rowdata,”rnrn”);
$body=substr($body,4,strlen($body));
return $body;
}

    return false;
}
?>

被禁用后的解决方法

服务器同时禁用了fsockopen pfsockopen,那么用其他函数代替,如stream_socket_client()。注意:stream_socket_client()和fsockopen()的参数不同。

fsockopen( 替换为 stream_socket_client( ,然后,将原fsockopen函数中的端口参数“80”删掉,并加到$host。

 代码如下 复制代码

$fp = fsockopen($host, 80, $errno, $errstr, 30);

$fp = fsockopen($host, $port, $errno, $errstr, $connection_timeout);
修改后:
$fp = stream_socket_client("tcp://".$host."80", $errno, $errstr, 30);

$fp = stream_socket_client("tcp://".$host.":".$port, $errno, $errstr, $connection_timeout);

上传文件HTML的输入标签FILE类型中的名称后要加[],作用是在HTML中向PHP建立数组,比如名称为pictures,多文件引用名称则为pictures[],实例如下:
 代码如下 复制代码

<form action=”upload.php” method=”post” enctype=”multipart/form-data”>
<p>
<input type=”file” name=”pictures[]” /><br />
<input type=”file” name=”pictures[]” /><br />
<input type=”file” name=”pictures[]” /><br />
<input type=”submit” value=”上传” />
</p>
</form> //手册中实例。

选择文件后点击上传

 代码如下 复制代码

<?php
print_r($_FILES);
?>

查看源文件:

 代码如下 复制代码
Array
(
[pictures] => Array
(
[name] => Array
(
[0] => file1.txt
[1] => file2.txt
[2] => file3.txt
)
[type] => Array
(
[0] => application/octet-stream
[1] => application/octet-stream
[2] => application/octet-stream
)
[tmp_name] => Array
(
[0] => D:EasyPHP\tmpphp47.tmp
[1] => D:EasyPHP\tmpphp48.tmp
[2] => D:EasyPHP\tmpphp49.tmp
)
[error] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
[size] => Array
(
[0] => 94289
[1] => 65536
[2] => 102400
)
)
)

假设名为 /file1.txt??和 /file2.txt 的文件被提交,则 $_FILES['pictures']['name'][0] 的值将是 file1.txt,而 $_FILES['pictures']['name'][1] 的值将是 file2.txt。类似的,$_FILES['file2.txt']['size'][0] 将包含文件 file1.txt 的大小,

有了上面信息了我们要实现多文件上传就简单了

 代码如下 复制代码

<?php

class upload {
public $up_ext=array(), $up_max=5210, $up_dir;
private $up_name, $up_rename=true, $up_num=0, $up_files=array(), $up_ret=array();

function __construct($name, $ext=array(), $rename=true) {
if (!empty($name)) {
$this->up_name = $name;
!empty($ext) && $this->up_ext = $ext;
$this->up_rename = $rename;
$this->up_dir = website_dirroot.
$globals['cfg_upload_path'];
$this->initupload();
} else {
exit('upload文件域名称为空,初始化失败!');
}
}

private function initupload() {
if (is_array($_files[$this->up_name])) {
$up_arr = count($_files[$this->up_name]);
$up_all = count($_files[$this->up_name], 1);
$up_cnt = ($up_all - $up_arr) / $up_arr;
for ($i = 0; $i < $up_cnt; $i ++) {
if ($_files[$this->up_name]['error'][$i] != 4) {
$this->up_files[] = array(
'tmp_name' => $_files[$this->up_name]['tmp_name'][$i],
'name' => $_files[$this->up_name]['name'][$i],
'type' => $_files[$this->up_name]['type'][$i],
'size' => $_files[$this->up_name]['size'][$i],
'error' => $_files[$this->up_name]['error'][$i]
);
}
}
$this->up_num = count($this->up_files);
} else {
if (isset($_files[$this->up_name])) {
$this->up_files = array(
'tmp_name' => $_files[$this->up_name]['tmp_name'],
'name' => $_files[$this->up_name]['name'],
'type' => $_files[$this->up_name]['type'],
'size' => $_files[$this->up_name]['size'],
'error' => $_files[$this->up_name]['error']
);
$this->up_num = 1;
} else {
exit('没找找到需要upload的文件!');
}
}

$this->chkupload();
}

private function chkupload() {
if (empty($this->up_ext)) {
$up_mime = array('image/wbmp', 'image/bmp', 'image/gif', 'image/pjpeg', 'image/x-png');
foreach ($this->up_files as $up_file) {
$up_allw = false;
foreach ($up_mime as $mime) {
if ($up_file['type'] == $mime) {
$up_allw = true; break;
}
}
!$up_allw && exit('不允许上传'.$up_file['type'].'格式的文件!');

if ($up_file['size'] / 1024 > $this->up_max) {
exit('不允许上传大于 '.$this->up_max.'k 的文件!');
}
}
} else {
foreach ($this->up_files as $up_file) {
$up_ext = end(explode('.', $up_file['name']));

$up_allw = false;
foreach ($this->up_ext as $ext) {
if ($up_ext == $ext) {
$up_allw = true; break;
}
}
!$up_allw && exit('不允许上传.'.$up_ext.'格式的文件!');

if ($up_file['size'] / 1024 > $this->up_max) {
exit('不允许上传大于 '.$this->up_max.'k 的文件!');
}
}
}

$this->uploading();
}

private function uploading() {
if (io::dircreate($this->up_dir)) {
if (chmod($this->up_dir, 0777)) {
if (!empty($this->up_files)) {
foreach ($this->up_files as $up_file) {
if (is_uploaded_file($up_file['tmp_name'])) {
$file_name = $up_file['name'];
if ($this->up_rename) {
$file_ext = end(explode('.', $file_name));
$file_rnd = substr(md5(uniqid()), mt_rand(0, 26), 6);
$file_name = date('ymdhis').'_'.$file_rnd.'.'.$file_ext;
}
$file_name = $this->up_dir.'/'.$file_name;

if (move_uploaded_file($up_file['tmp_name'], $file_name)) {
$this->up_ret[] = str_replace(website_dirroot, '', $file_name);
} else {
exit('文件上传失败!');
}
}
}
}
} else {
exit('未开启写入权限!');
}
} else {
exit('上传目录创建失败!');
}
}

public function getupload() {
return empty($this->up_ret) ? false : $this->up_ret;
}

function __destruct() {}
}
?>

在上面我们会看到一个for ($i = 0; $i < $up_cnt; $i ++) ,这个是遍历我们上面讲的一个个实例了。

[!--infotagslink--]

相关文章

  • php读取zip文件(删除文件,提取文件,增加文件)实例

    下面小编来给大家演示几个php操作zip文件的实例,我们可以读取zip包中指定文件与删除zip包中指定文件,下面来给大这介绍一下。 从zip压缩文件中提取文件 代...2016-11-25
  • Jupyter Notebook读取csv文件出现的问题及解决

    这篇文章主要介绍了JupyterNotebook读取csv文件出现的问题及解决,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2023-01-06
  • c#自带缓存使用方法 c#移除清理缓存

    这篇文章主要介绍了c#自带缓存使用方法,包括获取数据缓存、设置数据缓存、移除指定数据缓存等方法,需要的朋友可以参考下...2020-06-25
  • Photoshop打开PSD文件空白怎么解决

    有时我们接受或下载到的PSD文件打开是空白的,那么我们要如何来解决这个 问题了,下面一聚教程小伙伴就为各位介绍Photoshop打开PSD文件空白解决办法。 1、如我们打开...2016-09-14
  • 解决python 使用openpyxl读写大文件的坑

    这篇文章主要介绍了解决python 使用openpyxl读写大文件的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-13
  • C#实现HTTP下载文件的方法

    这篇文章主要介绍了C#实现HTTP下载文件的方法,包括了HTTP通信的创建、本地文件的写入等,非常具有实用价值,需要的朋友可以参考下...2020-06-25
  • SpringBoot实现excel文件生成和下载

    这篇文章主要为大家详细介绍了SpringBoot实现excel文件生成和下载,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-09
  • C#操作本地文件及保存文件到数据库的基本方法总结

    C#使用System.IO中的文件操作方法在Windows系统中处理本地文件相当顺手,这里我们还总结了在Oracle中保存文件的方法,嗯,接下来就来看看整理的C#操作本地文件及保存文件到数据库的基本方法总结...2020-06-25
  • php无刷新利用iframe实现页面无刷新上传文件(1/2)

    利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25
  • IDEA中的clean,清除项目缓存图文教程

    这篇文章主要介绍了IDEA中的clean,清除项目缓存图文教程,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-09-25
  • php批量替换内容或指定目录下所有文件内容

    要替换字符串中的内容我们只要利用php相关函数,如strstr,str_replace,正则表达式了,那么我们要替换目录所有文件的内容就需要先遍历目录再打开文件再利用上面讲的函数替...2016-11-25
  • PHP文件上传一些小收获

    又码了一个周末的代码,这次在做一些关于文件上传的东西。(PHP UPLOAD)小有收获项目是一个BT种子列表,用户有权限上传自己的种子,然后配合BT TRACK服务器把种子的信息写出来...2016-11-25
  • Zend studio文件注释模板设置方法

    步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
  • AI源文件转photoshop图像变模糊问题解决教程

    今天小编在这里就来给photoshop的这一款软件的使用者们来说下AI源文件转photoshop图像变模糊问题的解决教程,各位想知道具体解决方法的使用者们,那么下面就快来跟着小编...2016-09-14
  • C++万能库头文件在vs中的安装步骤(图文)

    这篇文章主要介绍了C++万能库头文件在vs中的安装步骤(图文),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-23
  • php文件上传你必须知道的几点

    本篇文章主要说明的是与php文件上传的相关配置的知识点。PHP文件上传功能配置主要涉及php.ini配置文件中的upload_tmp_dir、upload_max_filesize、post_max_size等选项,下面一一说明。打开php.ini配置文件找到File Upl...2015-10-21
  • ant design中upload组件上传大文件,显示进度条进度的实例

    这篇文章主要介绍了ant design中upload组件上传大文件,显示进度条进度的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-10-29
  • C#使用StreamWriter写入文件的方法

    这篇文章主要介绍了C#使用StreamWriter写入文件的方法,涉及C#中StreamWriter类操作文件的相关技巧,需要的朋友可以参考下...2020-06-25
  • php实现文件下载实例分享

    举一个案例:复制代码 代码如下:<?phpclass Downfile { function downserver($file_name){$file_path = "./img/".$file_name;//转码,文件名转为gb2312解决中文乱码$file_name = iconv("utf-8","gb2312",$file_name...2014-06-07
  • C#路径,文件,目录及IO常见操作汇总

    这篇文章主要介绍了C#路径,文件,目录及IO常见操作,较为详细的分析并汇总了C#关于路径,文件,目录及IO常见操作,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25