本文整理汇总了PHP中yii\web\UploadedFile::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadedFile::reset方法的具体用法?PHP UploadedFile::reset怎么用?PHP UploadedFile::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFiles
public function generateFiles($types)
{
$_FILES = [];
UploadedFile::reset();
foreach ($types as $index => $type) {
$file = "file.{$type}";
$path = Yii::getAlias("@tests/files/{$file}");
$_FILES["UploadForm[file][{$index}]"] = ['name' => $file, 'type' => mime_content_type($path), 'size' => filesize($path), 'tmp_name' => $path, 'error' => 0];
}
}
示例2: setUpBeforeClass
/**
* @inheritdoc
*/
public static function setUpBeforeClass()
{
try {
Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => 'sqlite::memory:']);
Yii::$app->getDb()->open();
$lines = explode(';', file_get_contents(__DIR__ . '/migrations/sqlite.sql'));
foreach ($lines as $line) {
if (trim($line) !== '') {
Yii::$app->getDb()->pdo->exec($line);
}
}
} catch (\Exception $e) {
Yii::$app->clear('db');
}
UploadedFile::reset();
}
示例3: _after
public function _after(\Codeception\TestCase $test)
{
$_SESSION = [];
$_FILES = [];
$_GET = [];
$_POST = [];
$_COOKIE = [];
$_REQUEST = [];
if ($this->transaction && $this->config['cleanup']) {
$this->transaction->rollback();
}
\yii\web\UploadedFile::reset();
if (Yii::$app) {
Yii::$app->session->destroy();
}
parent::_after($test);
}
示例4: save
public function save($runValidation = true, $attributes = NULL)
{
$class = get_class($this);
if ($class == 'Accounts') {
if (Accounts::findOne($this->id)) {
$this->isNewRecord = false;
}
}
$a = parent::save($runValidation, $attributes);
if ($a) {
//if (isset($_POST['Files'])) {
//$this->attributes = $_POST['Files'];
$tmps = \yii\web\UploadedFile::getInstancesByName('Files');
// proceed if the images have been set
if (isset($tmps) && count($tmps) > 0) {
\Yii::info('saved');
// go through each uploaded image
$configPath = \app\helpers\Linet3Helper::getSetting("company.path");
foreach ($tmps as $image => $pic) {
$img_add = new Files();
$img_add->name = $pic->name;
//it might be $img_add->name for you, filename is just what I chose to call it in my model
$img_add->path = "files/";
$img_add->parent_type = get_class($this);
$img_add->parent_id = $this->id;
// this links your picture model to the main model (like your user, or profile model)
$img_add->save();
// DONE
if ($pic->saveAs($img_add->getFullFilePath())) {
// add it to the main model now
} else {
echo 'Cannot upload!';
}
}
if (isset($_FILES)) {
Yii::info(print_r($_FILES, true));
unset($_FILES);
$tmps = \yii\web\UploadedFile::reset();
}
//}
}
}
//endFile
return $a;
}
示例5: afterSave
public function afterSave($insert, $changedAttributes)
{
$this->uploadFiles = array();
UploadedFile::reset();
$this->uploadFiles = UploadedFiles::getInstances($this, 'uploadFiles');
$_FILES = array();
if (!empty($this->uploadFiles)) {
if (!$this->upload()) {
return false;
}
}
return parent::afterSave($insert, $changedAttributes);
}
示例6: resetPersistentVars
public function resetPersistentVars()
{
static::$db = null;
static::$mailer = null;
\yii\web\UploadedFile::reset();
}