public static createFromFile ( string $path ) : ProtectedFile | ||
$path | string | Path to file |
Результат | ProtectedFile |
public static function createFromFile($path)
{
$file = new self();
$file->setSource($path);
return $file;
}
public function actionImport() { echo "<h1>Importing files:</h1>"; foreach (glob(Yii::app()->basePath . '/data/test/*') as $src_file) { $file = ProtectedFile::createFromFile($src_file); if (!$file->save()) { throw new CException('Cannot save file' . print_r($file->getErrors(), true)); } unlink($src_file); echo "<p>Imported " . $file->uid . ' - ' . $file->name . "</p>"; } echo "<p>Done!</p>"; }