博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

PHP 读取文件

Posted on 2012-07-17 15:47  bug yang  阅读(181)  评论(0编辑  收藏  举报

 

获取文件的长度

fseek(stream,   0,   SEEK_SET); 
filelen = ftell(fseek(stream,   0,   SEEK_END)); 
fseek(stream,   0,   SEEK_SET);
FILE   *stream; 
char   buf[1000]; 
int   filelen; 
stream=fopen( "c:\\a.txt ",   "w+ "); 
if(NULL   ==     stream)   return; 
fseek(stream,   0,   SEEK_SET); 
filelen   =   ftell(fseek(stream,   0,   SEEK_END)); 
fseek(stream,   0,   SEEK_SET); 
if(filelen   <=   sizeof(buff))   fread(buff,   filelen,   1,   stream); 
else   ...