cfile

Commonly used functions for filesystem objects manipulation
73 followers

This extension offers commonly used functions for filesystem objects (files and directories) manipulation. Can be used separately from Yii.

Repository at GitHub

Documentation, changelog, issue tracker and more are at CFile project repository at GitHub


CFile exposes:

Properties

  • exists
  • isdir
  • isfile
  • isempty
  • isuploaded
  • readable
  • writeable
  • realpath
  • basename (setter available)
  • filename (setter available)
  • dirname
  • extension (setter available)
  • mimeType
  • timeModified
  • size
  • owner (setter available)
  • group (setter available)
  • permissions (setter available)

Methods

  • Create
  • CreateDir
  • Purge
  • Contents (get; set for files, append possible; contents filters for directories)
  • Copy
  • Rename/Move
  • Send/Download ('x-sendfile' header support)
  • Delete

Total 20 comments

#12982 report it
Trejder at 2013/04/25 04:29am
@Vitalets

Support for FTP and other protocols is native in PHP at most file-operating functions. See "Supported Protocols and Wrappers". This means, that you should be able to simply use any of supported protocols (for example file://) when specifing file name via CFile->filename.

#12981 report it
Trejder at 2013/04/25 04:21am
Base class

CFile is currently based on CApplicationComponent. Consider, if you could base it on CFileHelper. This way users of your extension can have access to functions offered by both file-related classes.

#11806 report it
roadrunner at 2013/02/05 02:35am
it copy very slow

Hi when i use cfile it takes time to copy and sometime error shows Maximum execution time of 30 seconds, how can i speed up copy? also it needs to refresh if loading is stop to continue the copy. and how can i put an ajax their or i want that something loading .gif is show while it still copying????

on the other hand, it cool extension.....

#8728 report it
Vitalets at 2012/06/22 03:41am
ftp

good extension! It would be cool to add FTP support as all used php functions support it now.

#7619 report it
Raoul at 2012/04/03 11:14am
oups

Same here : NEKUDOTAYIM etc ... error on win platform - php 5.2.11

#7515 report it
BornToDrink at 2012/03/27 09:55am
Good Extension

But I have an issue on the Linux server (on Win localhost works), maybe it's the PHP version: Unexpected T_PAAMAYIM_NEKUDOTAYIM CFile.php lines 215 and 216. Now working with $this instead of ::

#6591 report it
jmariani at 2012/01/19 06:49pm
Thumbs up!

Thank you!

#4593 report it
got 2 doodle at 2011/07/23 12:51pm
Problem with permissions

I couldn't get this extension to create a directory with the correct permissions on my production server, not 100% sure why. Safe_mode is off.

I tried this

$imageTopFolder->createDir('0754',$path.$this->eventImageTemp);

But no joy! After much hair pulling I did this based on info from php.net and from looking at the Yii assets manager code.

$oldumask = umask(0);
@mkdir($path.$this->eventImageTemp, 0754); // or even 01777 so you get the sticky bit set
@umask($oldumask);

I don't know if others have had this problem.

#2898 report it
stutteringp0et at 2011/02/23 02:29pm
resubmitting...sorry

Sorry, that was supposed to look like this

$xsendfile=(in_array('mod_xsendfile',apache_get_modules()))?true:false;
#2897 report it
stutteringp0et at 2011/02/23 02:27pm
detecting xsendfile

Documentation (above) says: If CFile::download() second parameter ('serverHandled') is set to True...

Why not detect it within the method? [code] $xsendfile=(in_array('mod_xsendfile',apache_get_modules()))?true:false; [/code]

#2424 report it
gawronzo at 2010/12/29 04:36am
please disable one feature

Hi idle,

I have one suggestion. What do you think about disabling file size formatting while $greedy parameter of "set" function is "true" ? Now autoloaded file data contains formated size by default ...

Regards, gawronzo

#2374 report it
chux at 2010/12/18 05:12pm
Great!

Sir, you saved me a lot of time with this stuff.

Gracias!

#2001 report it
Parcouss at 2010/10/28 05:56pm
Really good extension

Thank you for the work, that' really a good extension.

#1932 report it
Nacesprin at 2010/10/17 10:37am
Error mb_substr_count() [<a href='function.mb-substr-count'>function.mb-substr-count</a>]: Unknown encoding &quot;63&quot;

Hello. Trying this....

$cfileDir = Yii::app()->file->set('ext.file');
    print_r($cfileDir->getContents(false,'php'));

I get follow errors:

Description
 
mb_substr_count() [<a href='function.mb-substr-count'>function.mb-substr-count</a>]: Unknown encoding &quot;63&quot;
Source File
 
C:\EasyPHP 2.0b1\www\yii-miniweb\protected\extensions\file\CFile.php(864)
 
00852:      */
00853:     private function filterPassed($str, $filter)
00854:     {
00855:         $passed = false;
00856: 
00857:         if ($filter!==null)
00858:         {
00859:             foreach ($filter as $rule)
00860:             {
00861:                 if ($rule[0]!='/')
00862:                 {
00863:                     $rule = '.'.$rule;
00864: $passed = (bool)substr_count($str, $rule, strlen($str)-strlen($rule));
00865:                 }
00866:                 else
00867:                     $passed = (bool)preg_match($rule, $str);
00868: 
00869:                 if ($passed)
00870:                     break;
00871:             }
00872:         } 
00873:         else
00874:             $passed = true;
00875: 
00876:         return $passed;
#325 report it
heyhoo at 2010/07/09 09:15am
Great

Great extension!

#642 report it
yugene at 2010/04/01 07:04am
great

Really usefull and handy. Thanks a lot.

#688 report it
Koneko13 at 2010/03/18 08:31am
Must have extension!

Really useful.

#1104 report it
Spyros at 2009/12/08 03:34am
That's Great

Very usefull, saved me a lot of time :)

#1105 report it
idle sign at 2009/12/07 11:56pm
Re: is this free?

@jackiesun: As free as in beer, why would you think it is not? :)

#1106 report it
jackiesun at 2009/12/07 09:18pm
is this free?

is this free?

Leave a comment

Please to leave your comment.

Create extension