Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UploadController extends Controller{
- function actionIndex(){
- $currentUser = User::model()->findByPk(Yii::app()->user->id);
- $company = $currentUser->company;
- $files = $company->files;
- $dir = Yii::getPathOfAlias('application.uploads');
- // $dir = $mainUploadDir . '\company_1000'. echo $company->id;
- $uploaded = false;
- $model = new Upload();
- if (isset($_POST['Upload'])){
- $model->attributes = $_POST['Upload'];
- $file = CUploadedFile::getInstance($model, 'file');
- //$model->author = $currentUser->name;
- $model->company_id = $company;
- $model->originalName = $file->getName();
- $model->uniqName = rand('1', time());
- $model->author = $currentUser->name;
- $model->company_id = $company;
- $model->downloadPath = 'www.planster.org/uploads/'. 'compnay_'. "echo $company_id" . "/" . $model->uniqName;
- if ($model->save()) {
- $uploaded = $file->saveAs($dir . '/' . $model->uniqName);
- //$model->uploadTime = new CDbExpression('NOW()');
- //Yii::app()->user->setFlash('success','Загрузка успешно завершена!');
- //$this->refresh();
- }
- }
- $this->render('index', array(
- 'model'=>$model,
- 'uploaded' => $uploaded,
- 'dir' => $dir,
- 'files' => $files,
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement