Beispiel #1
0
<?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";
}
 /**
  * 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)));
 }