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


PHP File::create方法代码示例

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


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

示例1: 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

示例2: handle

 /**
  * Handles the file upload
  *
  * @param array $input [description]
  *
  * @return array Variable response - either pending or file uploaded when all chunks
  *               are received.
  */
 public function handle($input = array())
 {
     $validator = Validator::make($input, Model::$rules);
     $user = User::find($input['user_id']);
     if ($validator->fails()) {
         throw new Exception("Validation Issues", 500);
     }
     $filename = time() . $input['flowFilename'];
     $input['original_filename'] = $input['flowFilename'];
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $filename = pathinfo($filename, PATHINFO_FILENAME);
     if (!isset($input['path'])) {
         $input['path'] = $user->id . '/';
     }
     $storageLocation = storage_path('user-data/' . $input['path']);
     if (!is_dir($storageLocation)) {
         mkdir($storageLocation, 0755, true);
     }
     $config = new FlowConfig();
     if (!is_dir($storageLocation . 'chunks')) {
         mkdir($storageLocation . 'chunks', 0755, true);
     }
     $config->setTempDir($storageLocation . 'chunks');
     $file = new FlowFile($config);
     if (isset($_POST['ie-app'])) {
         $file->saveChunk();
     } else {
         if ($file->validateChunk()) {
             $file->saveChunk();
         } else {
             // error, invalid chunk upload request, retry
             throw new Exception('Bad request', 400);
         }
     }
     $filename = $this->sanitizeString($filename) . '.' . $extension;
     $localPath = $storageLocation . $filename;
     if ($file->validateFile() && $file->save($localPath)) {
         $input['status'] = 'saved';
         $input['size'] = $input['flowTotalSize'];
         if (isset($_POST['ie-app'])) {
             $input['size'] = filesize($localPath);
         } else {
             $input['size'] = $input['flowTotalSize'];
         }
         $input['path'] = $input['path'] . $filename;
         $input['filename'] = $filename;
         $input['type'] = mime_content_type($localPath);
         $file = Model::create($input);
         //FIXME should use the transformer
         return ['id' => $file->id, 'path' => $file->path, 'links' => $file->links, 'original_filename' => $file->original_filename];
     } else {
         // This is not a final chunk, continue to upload
         return array('pending' => true);
     }
 }
开发者ID:GoohegWeb,项目名称:file-sharing,代码行数:63,代码来源:Files.php

示例3: document

 public function document()
 {
     $user = Session::read('member');
     $id = md5($user['email']);
     $document = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id'])));
     //		if(count($document)==0){return $this->redirect('/');}
     $uploadOk = 1;
     if ($this->request->data) {
         $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         $allowed = array('pdf');
         if (!in_array(strtolower($extension), $allowed)) {
             $msg = "Sorry, only PDF files are allowed.";
             $uploadOk = 0;
         }
         if ($uploadOk = 1) {
             $option = 'doc';
             $data = array('details_' . $option . '_id' => (string) $document['_id'], 'docname' => $this->request->data['docname'], 'date' => $this->request->data['date'], 'DateTime' => new \MongoDate(), 'keywords' => $this->request->data['keywords'], 'description' => $this->request->data['description'], $option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
             $field = 'details_' . $option . '_id';
             $Documents = Documents::create($data);
             $saved = $Documents->save();
             $fileData = array('file' => $this->request->data['file'], 'documents_' . $option . '_id' => (string) $Documents->_id);
             $file = File::create();
             if ($file->save($fileData)) {
                 $msg = "Upload OK";
             }
             $image_address = File::find('first', array('conditions' => array('documents_doc_id' => (string) $Documents->_id)));
             if ($image_address['filename'] != "") {
                 $imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
                 $path = LITHIUM_APP_PATH . '/webroot/download/' . $imagename_address;
                 file_put_contents($path, $image_address->file->getBytes());
             }
             //		print_r($path);
             $pages = $this->getPDFPages($path);
             // Output: 13
             //				print_r($pages);exit;
             unlink($path);
             $docdata = array();
             foreach ($pages as $page) {
                 $params = explode(":", $page);
                 $left = $params[0];
                 $right = $params[1];
                 $docdata = array_merge($docdata, array($left => trim($right)));
             }
             $data = array("document" => $docdata);
             $conditions = array("_id" => (string) $Documents->_id);
             Documents::update($data, $conditions);
             // Use the function
         }
     }
     return $this->redirect('ex::save');
 }
开发者ID:nilamdoc,项目名称:OxOPDF,代码行数:51,代码来源:UploadController.php

示例4: saveUpload

 public static function saveUpload($file, $user, $folder = null)
 {
     $filename = $file->getClientOriginalName();
     $extension = $file->getClientOriginalExtension();
     $ext = Extension::firstOrCreate(["name" => strtolower($extension)]);
     $path = "fileuploads/";
     $uploaded_file_name = str_random("10") . $filename;
     $upload_path = $path . $uploaded_file_name;
     $file->move(public_path($path), $uploaded_file_name);
     $data = ["name" => $filename, "extension_id" => $ext->id, "path" => $upload_path, "created_by" => $user->id];
     if ($folder != null) {
         $data["folder_id"] = $folder->id;
     }
     $obj = File::create($data);
     return $obj;
 }
开发者ID:ravimalik20,项目名称:docsManage,代码行数:16,代码来源:File.php

示例5: store

 public function store(Request $request, $banqueId)
 {
     // verify request inputs
     if (is_null($banqueId)) {
         return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
     } else {
         // verify request inputs
         $file = $request->file('file');
         if ($file->isValid()) {
             $chemin = config('file.path');
             $extension = $file->getClientOriginalExtension();
             do {
                 $nom = str_random(10) . '.' . $extension;
             } while (file_exists($chemin . '/' . $nom));
             if ($file->move($chemin, $nom)) {
                 $f = File::create(['chemin' => $chemin . '/' . $nom, 'id_Banque' => $banqueId]);
             }
         }
     }
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:20,代码来源:FileController.php

示例6: settings

 public function settings($option = null)
 {
     $title = "User settings";
     $ga = new GoogleAuthenticator();
     $user = Session::read('default');
     if ($user == "") {
         return $this->redirect('/login');
     }
     $id = $user['_id'];
     $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
     $uploadOk = 1;
     $qrCodeUrl = $ga->getQRCodeGoogleUrl(COMPANY_URL . "-" . $details['username'], $details['secret']);
     if ($this->request->data) {
         $imageFileType = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
             $msg = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
             $uploadOk = 0;
             return $this->redirect('Users::settings', compact('msg'));
         }
         if ($uploadOk = 1) {
             $option = $this->request->data['option'];
             $data = array($option => $this->request->data['file'], $option . '.verified' => 'No');
             $field = 'details_' . $option . '_id';
             $remove = File::remove('all', array('conditions' => array($field => (string) $details->_id)));
             $fileData = array('file' => $this->request->data['file'], 'details_' . $option . '_id' => (string) $details->_id);
             $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)))->save($data);
             $file = File::create();
             if ($file->save($fileData)) {
                 $this->redirect('ex::dashboard');
             }
         }
         $TOTP = $details['TOTP.Validate'];
         $secret = $details['secret'];
     }
     $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
     $image_address = File::find('first', array('conditions' => array('details_address_id' => (string) $details['_id'])));
     if ($image_address['filename'] != "") {
         $imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_address;
         file_put_contents($path, $image_address->file->getBytes());
     }
     $image_government = File::find('first', array('conditions' => array('details_government_id' => (string) $details['_id'])));
     if ($image_government['filename'] != "") {
         $imagename_government = $image_government['_id'] . '_' . $image_government['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_government;
         file_put_contents($path, $image_government->file->getBytes());
     }
     $image_bank = File::find('first', array('conditions' => array('details_bank_id' => (string) $details['_id'])));
     if ($image_bank['filename'] != "") {
         $imagename_bank = $image_bank['_id'] . '_' . $image_bank['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_bank;
         file_put_contents($path, $image_bank->file->getBytes());
     }
     $settings = Settings::find('first');
     return compact('details', 'user', 'title', 'qrCodeUrl', 'secret', 'option', 'imagename_address', 'imagename_government', 'imagename_bank', 'settings', 'msg');
 }
开发者ID:nilamdoc,项目名称:msx,代码行数:56,代码来源:UsersController.php

示例7: save

 public function save()
 {
     //		print_r($this->request->data);
     if ($this->request->data) {
         $data = $this->request->data;
         $fileData = array('file' => $this->request->data['blob'], 'details_video_id' => (string) $data['video-id']);
         $field = 'details_video_id';
         $remove = File::remove('all', array('conditions' => array($field => (string) $data['video-id'])));
         Documents::find('first', array('conditions' => array('_id' => (string) $data['video-id'])))->save($data);
         $file = File::create();
         if ($file->save($fileData)) {
             $msg = "Upload OK";
         }
     }
     return $this->render(array('json' => array('success' => 0)));
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:16,代码来源:ProcessController.php

示例8: companyupload

 public function companyupload($id = null, $type = "corporation")
 {
     $company = Companies::find('first', array('conditions' => array('hash' => $id)));
     if (count($company) == 0) {
         return $this->redirect('kyc::index');
     }
     $uploadOk = 1;
     if ($this->request->data) {
         $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         $allowed = array('jpg', 'jpeg', 'png', 'gif');
         if (!in_array(strtolower($extension), $allowed)) {
             $msg = "Sorry, only JPG, PNG, GIF file is allowed.";
             $uploadOk = 0;
         }
         if (strtolower($extension) == 'pdf') {
             $msg = "Please do not upload PDF file.";
             $uploadOk = 0;
         }
         $size = round($this->request->data['file']['size'] / 1024 / 1024, 2);
         if ($size >= 10) {
             $msg = "Sorry, File too large, should be less than 10 MB. It is " . $size . "MB!";
             $uploadOk = 0;
         }
         if ($uploadOk == 1) {
             $option = $this->request->data['option'];
             $data = array($option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
             $field = 'details_' . $option . '_id';
             $remove = File::remove('all', array('conditions' => array($field => (string) $company['_id'])));
             $path = LITHIUM_APP_PATH . '\\webroot\\documents\\';
             $resizedFile = $path . $this->request->data['file']['name'];
             $resizedFileServer = 'https://' . $_SERVER['SERVER_NAME'] . '/documents/' . $this->request->data['file']['name'];
             $resize = $this->smart_resize_image($this->request->data['file']['tmp_name'], null, 1024, 0, true, $resizedFile, false, false, 100);
             if ($resize == false) {
                 $msg = "File format different, cannot verify.";
                 $uploadOk = 0;
             }
             $fileData = array('file' => file_get_contents($resizedFile), 'filename' => $this->request->data['file']['name'], 'metadata' => array('filename' => $this->request->data['file']['name']), 'details_' . $option . '_id' => (string) $document['_id']);
             Companies::find('first', array('conditions' => array('_id' => (string) $company['_id'])))->save($data);
             $file = File::create();
             if ($file->save($fileData)) {
                 $msg = "Upload OK";
             }
             unlink($resizedFile);
         }
     }
     $image_corporation = File::find('first', array('conditions' => array('details_corporation_id' => (string) $company['_id'])));
     if ($image_corporation['filename'] != "") {
         $imagename_corporation = $image_corporation['_id'] . '_' . $image_corporation['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_corporation;
         file_put_contents($path, $image_corporation->file->getBytes());
     }
     $image_articles = File::find('first', array('conditions' => array('details_articles_id' => (string) $company['_id'])));
     if ($image_articles['filename'] != "") {
         $imagename_articles = $image_articles['_id'] . '_' . $image_articles['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_articles;
         file_put_contents($path, $image_articles->file->getBytes());
     }
     $image_resolution = File::find('first', array('conditions' => array('details_resolution_id' => (string) $company['_id'])));
     if ($image_resolution['filename'] != "") {
         $imagename_resolution = $image_resolution['_id'] . '_' . $image_resolution['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_resolution;
         file_put_contents($path, $image_resolution->file->getBytes());
     }
     $image_directors = File::find('first', array('conditions' => array('details_directors_id' => (string) $company['_id'])));
     if ($image_directors['filename'] != "") {
         $imagename_directors = $image_directors['_id'] . '_' . $image_directors['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_directors;
         file_put_contents($path, $image_directors->file->getBytes());
     }
     return compact('company', 'countries', 'imagename_corporation', 'imagename_articles', 'imagename_resolution', 'imagename_directors', 'msg', 'type');
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:71,代码来源:KycController.php


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