本文整理汇总了PHP中FileUploader::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUploader::hasFile方法的具体用法?PHP FileUploader::hasFile怎么用?PHP FileUploader::hasFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUploader
的用法示例。
在下文中一共展示了FileUploader::hasFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
require_once dirname(__FILE__) . './../vendors/yii-1.1.8/framework/yii.php';
include_once dirname(__FILE__) . '/../admin/protected/service/FileUploader.php';
error_reporting(0);
try {
if (!FileUploader::hasFile('xfile')) {
throw new Exception();
}
$filename = $_POST['xfilename'];
if (!isset($filename)) {
$filename = 'test_' . rand(0, 10000);
}
$info = pathinfo($filename);
$filePath = FileUploader::uploadFileLocal('xfile', $info['basename']);
if ($filePath == null) {
throw new Exception();
}
echo $filePath;
} catch (Exception $e) {
echo "ERROR";
}
示例2: actionSaveShemaObject
/**
* Save shema object. All params must be passed vie POST method.
*/
public function actionSaveShemaObject()
{
if (!isset($_POST['shema'])) {
die('Invalid shema');
}
//TODO
$attr = $_POST;
$type = $attr['shema'];
if (FileUploader::hasFile('xfile')) {
$attr['text_value'] = FileUploader::uploadFile('xfile');
}
$object = DataModelFactory::createDataObjectWithType($type);
$object->setAttributes($attr);
$storage = DataStorageFactory::createDataStorageWithType($type);
$storage->save($object);
$this->redirect(Yii::app()->createUrl('manager/shema', array('shema' => $type)));
}