当前位置: 首页>>代码示例>>PHP>>正文


PHP models\File类代码示例

本文整理汇总了PHP中app\models\File的典型用法代码示例。如果您正苦于以下问题:PHP File类的具体用法?PHP File怎么用?PHP File使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save()
 {
     if (isset($this->reading) and $this->reading != '') {
         $savemodel = new Calibration();
         $savemodel->measure = 'mm';
         $savemodel->height = $this->reading;
         $savemodel->sensorid = $this->sensorid;
         $savemodel->datetime = $this->date;
         $savemodel->youremail = $this->youremail;
         $savemodel->yourname = $this->yourname;
         $result = $savemodel->save();
         $this->id = $savemodel->sensorid;
         return $result;
     } else {
         $savemodel = new File();
         $savemodel->sensorid = $this->sensorid;
         $savemodel->startdate = $this->date;
         $savemodel->enddate = $this->date;
         $savemodel->status = 'processed';
         $this->file = UploadedFile::getInstance($this, 'file');
         $savemodel->extension = end(explode(".", $this->file->name));
         $result = $savemodel->save();
         // save to get the ID
         $savemodel->filename = $savemodel->id . "_" . $this->file->name;
         $path = Yii::getAlias('@app') . Yii::$app->params['uploadPath'] . $savemodel->filename;
         if ($result) {
             $this->file->saveAs($path);
         }
         $result = $savemodel->save();
         $this->id = $savemodel->sensorid;
         return $result;
     }
 }
开发者ID:ICHydro,项目名称:anaconda,代码行数:33,代码来源:UploaddataForm.php

示例2: UploadFile

 public static function UploadFile($request)
 {
     $type = FileType::findOrFail($request->input('file_type_id'));
     $file = new File();
     $filename = uniqid();
     $newname = $request->input('newname');
     if ($request->hasFile('file')) {
         if (isset($newname[0])) {
             $file->slug = str_replace(['/', '\\'], '', $newname);
         } else {
             $file->slug = $filename;
         }
         $file->filename = $filename;
         $file->file_ext = $request->file('file')->getClientOriginalExtension();
         $file->path_to_file = 'uploads/files/';
         if ($type->image) {
             $file->path_to_file = 'uploads/images/';
         }
         $destinationPath = public_path($file->path_to_file);
         $request->file('file')->move($destinationPath, $filename . '.' . $file->file_ext);
         $file->path_to_file = '/' . $file->path_to_file;
         $file->file_type_id = $type->id;
         $file->fullname = $file->filename . '.' . $file->file_ext;
         $file->description = $request->input('description');
         $file->alt_text = $request->input('alt_text');
         $file->uploader = null;
         $file->path_to_file = $file->path_to_file . $file->fullname;
         $file->save();
         return redirect()->action('FilesController@index');
     }
     return back()->withErrors(['File not found. Please try again']);
 }
开发者ID:jardayn,项目名称:portfolio,代码行数:32,代码来源:FileUpload.php

示例3: create

 public static function create(array $data = array())
 {
     $file = new File();
     $file->fill($data);
     $file->save();
     $element = new Element();
     $element->fill($data);
     $file->content()->save($element);
 }
开发者ID:emmanuelsf,项目名称:xdrawerl,代码行数:9,代码来源:File.php

示例4: testGenerateName

 public function testGenerateName()
 {
     $file = new File();
     $file->generateName('png');
     $pathinfo = pathinfo($file->name);
     expect($pathinfo)->hasKey('basename');
     expect($pathinfo)->hasKey('filename');
     expect($pathinfo)->hasKey('extension');
     expect($pathinfo['extension'])->equals('png');
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:10,代码来源:FileTest.php

示例5: actionSave

 public function actionSave()
 {
     $item = new File();
     $periodStart = date('Y-m-d', strtotime($this->app->request->post->periodStart));
     $periodEnd = date('Y-m-d', strtotime($this->app->request->post->periodEnd));
     $this->app->request->post->periodStart = $periodStart;
     $this->app->request->post->periodEnd = $periodEnd;
     $item->fill($this->app->request->post);
     $item->save();
     $this->redirect('/sources/default/');
 }
开发者ID:Alexandr1987,项目名称:barricade,代码行数:11,代码来源:Sources.php

示例6: saveDriver

 /**
  * Save plugin file if its a valid file
  *
  * @param file object
  * @return String success/failure message
  */
 public static function saveDriver($file)
 {
     $fileName = $file->getClientOriginalName();
     $destination = app_path() . '/kblis/plugins/';
     try {
         $file->move($destination, $fileName);
     } catch (Exception $e) {
         Log::error($e);
         return trans('messages.unwriteable-destination-folder');
     }
     $className = "\\KBLIS\\Plugins\\" . head(explode(".", last(explode("/", $fileName))));
     // Check if the className is a valid plugin file
     if (class_exists($className)) {
         $dummyIP = "10.10.10.1";
         $instrument = new $className($dummyIP);
         if (is_subclass_of($instrument, '\\KBLIS\\Instrumentation\\AbstractInstrumentor')) {
             $instrument->getEquipmentInfo()['code'];
             return trans('messages.success-importing-driver');
         } else {
             Log::error("invalid-driver-file: " . $className);
         }
     }
     if (File::exists($destination . $fileName)) {
         File::delete($destination . $fileName);
     }
     return trans('messages.invalid-driver-file');
 }
开发者ID:echiteri,项目名称:iBLIS,代码行数:33,代码来源:Instrument.php

示例7: add

 public function add()
 {
     $login = Auth::check('member');
     if ($this->request->data) {
         $software = Software::create($this->request->data);
         if ($software->save()) {
             $file = File::create();
             foreach ($this->request->data['myfile'] as $key => $value) {
                 $size = $this->request->data['myfile'][$key]['size'];
                 if ($size >= 600000001) {
                     $chunksize = $size / 20;
                 } else {
                     if ($size <= 600000000 && $size >= 100000000) {
                         $chunksize = $size / 10;
                     } else {
                         if ($size <= 100000000 && $size >= 10000000) {
                             $chunksize = 10000000;
                         } else {
                             $chunksize = 1000000;
                         }
                     }
                 }
                 $save = $file->save(array('file' => $value, 'software_id' => (string) $software->_id, 'chunkSize' => 10000000));
                 if (!$save) {
                     return compact('save');
                 }
             }
         }
     }
     $software = Software::create();
     return compact('login', 'software');
 }
开发者ID:beeckmpi,项目名称:permanentielijsten,代码行数:32,代码来源:SoftwareController.php

示例8: actionEdit

 public function actionEdit($id = null)
 {
     if (null === $id || 'new' === $id) {
         $this->data->item = new File();
     } else {
         $this->data->item = File::findByPK($id);
     }
 }
开发者ID:Alexandr1987,项目名称:barricade,代码行数:8,代码来源:Files.php

示例9: findModel

 /**
  * Finds the File model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return File the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = File::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:andreyvaslv,项目名称:crb,代码行数:15,代码来源:FileController.php

示例10: setPathAttribute

 /**
  * Get the Complete Name for the user.
  *
  * @return string
  */
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $title = Carbon::now()->second . $path->getClientOriginalName();
         $this->attributes['path'] = $title;
         \Storage::disk('local')->put($title, \File::get($path));
     }
 }
开发者ID:alfons83,项目名称:tfg,代码行数:13,代码来源:User.php

示例11: saveFile

 protected function saveFile(UploadedFile $file)
 {
     $upload_dir = public_path('img/avatar');
     $file_name = 'images-' . date('dmY-His') . '.' . $file->getClientOriginalExtension();
     try {
         if ($file->move($upload_dir, $file_name)) {
             $file = new File();
             $file->setAttribute('name', $file_name);
             $file->setAttribute('path', $upload_dir);
             $file->save();
             return $file->id;
         } else {
             return null;
         }
     } catch (\Exception $ex) {
         return abort(500, $ex->getMessage());
     }
 }
开发者ID:juliardi,项目名称:jualjasa,代码行数:18,代码来源:ProfileController.php

示例12: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $filecount = \App\Models\File::where('file_type_id', $id)->count();
     if ($filecount > 0) {
         return back()->withMsg('There are files in the category');
     }
     FileType::findOrFail($id)->delete();
     return back();
 }
开发者ID:jardayn,项目名称:portfolio,代码行数:15,代码来源:FileTypesController.php

示例13: delete

 public function delete($id = null)
 {
     $user = Session::read('member');
     if ($user == "") {
         return $this->redirect('/');
     }
     $remove = File::remove('all', array('conditions' => array('documents_doc_id' => (string) $id)));
     $remove = Documents::remove('all', array('conditions' => array('_id' => (string) $id)));
     return $this->redirect('ex::dashboard');
 }
开发者ID:nilamdoc,项目名称:OxOPDF,代码行数:10,代码来源:ExController.php

示例14: assignFileToRecord

 public function assignFileToRecord($fileId, $recordId, $record_video_type)
 {
     $file = File::findOne($fileId);
     if (!$file) {
         throw new HttpException(500, 'No file found');
     }
     $file->record_id = $recordId;
     $file->record_file_type = $record_video_type;
     return $file->save(false);
 }
开发者ID:vfokov,项目名称:tims2,代码行数:10,代码来源:Media.php

示例15: delete

 public function delete(Request $request, $banqueId, $fileId)
 {
     // verify request inputs
     if (is_null($fileId)) {
         return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
     } else {
         $item = File::where('id_File', '=', $fileId)->delete();
         return is_null($item) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $item;
     }
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:10,代码来源:FileController.php


注:本文中的app\models\File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。