FuelPHP Fileクラス

Fileクラスは、ファイルとディレクトリを扱うさまざまなメソッドを提供する。

メソッド説明
copyファイルのコピー
deleteファイルの削除
downloadファイルのダウンロード
readファイルの読み出し

copy

public static function copy($path, $new_path, $area = null, $source_area = null, $target_area = null)

delete

public static function delete($path, $area = null)

$path
削除するファイルのパス
$area
エリアオブジェクト

download

download($path, $name = null, $mime = null, $area = null)

$path
ファイルのパス
$name
ファイルの名前
$mime
ファイルのMIMEタイプ

File::download(DOCROOT . 'index.php', 'newfile.php');

read

static int|string read($path, $as_string = false, $area = null);

$path
読み出すファイルのパス
$as_string
trueを指定した場合、file_get_contents関数で読み出す。falseを指定した場合、readfile関数を使ってファイルを読み出す。

rename

static function rename($path, $new_path, $source_area = null, $target_area = null)

$path
リネームするファイル又はディレクトリのパス
$new_path
新しいファイルまたはディレクトリのパス