當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::makeDirectory方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\File::makeDirectory方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::makeDirectory方法的具體用法?PHP File::makeDirectory怎麽用?PHP File::makeDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\File的用法示例。


在下文中一共展示了File::makeDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSubmissionVerdict

 public function getSubmissionVerdict($srcContent, $srcExt)
 {
     assert($srcExt == "cpp" || $srcExt == "java" || $srcExt == "py", "'Source code language must be C++, Java or Python'");
     $judgingBaseFolder = '../judging/';
     $submissionFolderName = uniqid();
     $submissionFolder = "{$judgingBaseFolder}{$submissionFolderName}/";
     // Write the source code file
     $srcFpath = "{$submissionFolder}main.{$srcExt}";
     File::makeDirectory($submissionFolder);
     File::put($srcFpath, $srcContent);
     // Create the required test case files
     $caseNo = 1;
     $testcases = $this->testcases()->get();
     foreach ($testcases as $tc) {
         $inFname = "test{$caseNo}.in";
         $outFname = "test{$caseNo}.ans";
         $inFpath = $submissionFolder . $inFname;
         $outFpath = $submissionFolder . $outFname;
         File::put($inFpath, $tc->input);
         File::put($outFpath, $tc->output);
         $caseNo += 1;
     }
     // Judge!
     $judgingScript = "python \"{$judgingBaseFolder}judge.py\"";
     $judgingArguments = sprintf('"%s" "%s" %d', $srcFpath, $submissionFolder, $this['time_limit']);
     $judgeCommand = "{$judgingScript} {$judgingArguments}";
     $verdict = shell_exec($judgeCommand);
     // Clean-up the submission directory
     File::deleteDirectory($submissionFolder);
     return $verdict;
 }
開發者ID:alexpizarroj,項目名稱:orange,代碼行數:31,代碼來源:Problem.php

示例2: saveImages

 protected function saveImages($image, $sid, $index)
 {
     $v = Validator::make(['index' => $index, 'id' => $sid], ['index' => 'required|integer', 'id' => 'required|integer']);
     if ($v->fails()) {
         dd('wrong sid =' . $sid);
     }
     try {
         $image = Image::make($image);
         // check the directories
         if (!File::exists($this->saveImgDir)) {
             File::makeDirectory($this->saveImgDir);
         }
         if (!File::exists($this->saveImgDir . '/products')) {
             File::makeDirectory($this->saveImgDir . '/products');
         }
         if (!File::exists($this->saveImgDir . '/products/' . $sid)) {
             File::makeDirectory($this->saveImgDir . '/products/' . $sid);
         }
         // dir to save image
         $dir = $this->saveImgDir . '/products/' . $sid . '/' . $index;
         if (!File::exists($dir)) {
             File::makeDirectory($dir);
         }
         // save medium
         $image->fit(240, 240)->save($dir . '/medium.jpg');
         $this->images[$index]['medium'] = 'mircurius/img/products/' . $sid . '/' . $index . '/medium.jpg';
     } catch (Exception $e) {
         $error = (array) $image;
         $this->log(json_encode($error));
         $this->log($e);
     }
 }
開發者ID:peshkov3,項目名稱:mircurius,代碼行數:32,代碼來源:ProductObserver.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['name' => ['required', 'unique:archive,name', 'regex:' . config('app.expressions.dir')]];
     if ($this->systemAdmin) {
         $rules['department_id'] = 'required';
     }
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     DB::transaction(function () use($request) {
         #add all papers from department to archive
         $archive = Archive::create($request->all());
         $department = Department::findOrFail($request->get('department_id'));
         $paperObj = new PaperClass();
         $archivePath = 'archive/';
         if (!File::exists($archivePath . $archive->name)) {
             File::makeDirectory($archivePath . $archive->name);
         }
         $newPath = $archivePath . $archive->name . '/';
         $oldPath = $paperObj->prefix() . '/' . $department->keyword . '/';
         foreach ($department->papers()->archived()->get() as $paper) {
             $paper->archive()->associate($archive);
             $paper->save();
             File::move($oldPath . $paper->source, $newPath . $paper->source);
             if ($paper->payment_source) {
                 File::move($oldPath . $paper->payment_source, $newPath . $paper->payment_source);
             }
         }
     });
     return redirect()->action('Admin\\ArchiveController@index')->with('success', 'updated');
 }
開發者ID:Tisho84,項目名稱:conference,代碼行數:38,代碼來源:ArchiveController.php

示例4: checkSharedFolderExists

 private function checkSharedFolderExists()
 {
     $path = base_path($this->file_location . Config::get('lfm.shared_folder_name'));
     if (!File::exists($path)) {
         File::makeDirectory($path, $mode = 0777, true, true);
     }
 }
開發者ID:Abdulhmid,項目名稱:inventory,代碼行數:7,代碼來源:LfmController.php

示例5: imageAvatar

 protected function imageAvatar()
 {
     $path = 'upload/' . date('Ym/d/');
     $filename = KRandom::getRandStr() . '.jpg';
     if (!File::exists(public_path($path))) {
         File::makeDirectory(public_path($path), 493, true);
     }
     while (File::exists(public_path($path) . $filename)) {
         $filename = KRandom::getRandStr() . '.jpg';
     }
     $this->image->resize(new \Imagine\Image\Box(300, 300))->save(public_path($path) . $filename);
     ImageModel::createUploadedImage($path . $filename, URL::asset($path . $filename));
     $user = AuthModel::user();
     $url = URL::asset($path . $filename);
     if ($user) {
         if ($user->profile) {
             $user->profile->avatar = $url;
             $user->profile->save();
         } else {
             ProfileModel::create(array('user_id' => $user->id, 'avatar' => $url));
         }
     } else {
     }
     return $url;
 }
開發者ID:xjtuwangke,項目名稱:laravel-cms,代碼行數:25,代碼來源:UploadifyController.php

示例6: checkSharedFolderExists

 private function checkSharedFolderExists()
 {
     $path = $this->getPath('share');
     if (!File::exists($path)) {
         File::makeDirectory($path, $mode = 0777, true, true);
     }
 }
開發者ID:it9xpro,項目名稱:laravel-filemanager,代碼行數:7,代碼來源:LfmController.php

示例7: upload

 public function upload(UploadRequest $request)
 {
     $type = $request->input('type');
     if ($request->ajax()) {
         //確認文件是否有上傳
         if ($request->hasFile('file')) {
             //code..
             $file = $request->file('file');
             if (!$file->isValid()) {
                 $result = ['status' => 'failed', 'msg' => '上傳文件無效!'];
             } else {
                 $extension = $file->getClientOriginalExtension();
                 //取得上傳文件的後綴名
                 $path = 'uploads/' . $type . '/';
                 $savePath = $path . date('Ymd', time());
                 File::exists($savePath) or File::makeDirectory($savePath, 0755, true);
                 $saveFileName = uniqid() . '_' . $type . '.' . $extension;
                 //函數基於以微秒計的當前時間,生成一個唯一的 ID。
                 $file->move($savePath, $saveFileName);
                 $fullFileName = $savePath . '/' . $saveFileName;
                 $result = ['status' => 'success', 'msg' => '上傳成功!', 'path' => $fullFileName];
             }
         } else {
             $result = ['status' => 'failed', 'msg' => '請選擇上傳文件!'];
         }
         return $result;
     }
 }
開發者ID:nutsdo,項目名稱:nong-store,代碼行數:28,代碼來源:UploadController.php

示例8: storeDiskSettingsBackEnd

 protected function storeDiskSettingsBackEnd($directory_name, $directory_driver, $is_directory_public = false)
 {
     $directory_url = null;
     $directory_root = null;
     $directory_path = null;
     $directory_name = str_replace('-', '_', slugify($directory_name));
     switch ($directory_driver) {
         case 'local':
         default:
             if ($is_directory_public) {
                 $directory_root = 'uploads/' . Environments::currentEnvironment() . '/' . $directory_name;
                 $directory_url = url($directory_root);
                 $directory_path = public_path($directory_root);
             } else {
                 $directory_root = 'app/' . Environments::currentEnvironment() . '/' . $directory_name;
                 $directory_url = url($directory_root);
                 $directory_path = public_path($directory_root);
             }
             break;
     }
     File::makeDirectory($directory_path, 0777, true);
     $disk = ['driver' => $directory_driver, 'root' => $directory_path];
     if ($is_directory_public) {
         $disk['visibility'] = 'public';
     }
     $this->addFileSystemDisk($directory_name, $disk, Environments::currentEnvironment());
     $this->mountElFinderDisk($directory_name, ['alias' => $directory_path, 'URL' => $directory_url, 'access' => ['readonly' => true, 'roles' => [RolesRepositoryEloquent::ADMIN], 'permissions' => [PermissionsRepositoryEloquent::CAN_READ_BACKUPS_DIRECTORY]]], Environments::currentEnvironment());
 }
開發者ID:cvepdb-cms,項目名稱:module-files,代碼行數:28,代碼來源:ElFinderDiskRepository.php

示例9: createTempDirectory

 /**
  * Create a directory to store some working files.
  *
  * @return string
  */
 public function createTempDirectory()
 {
     $tempDirectory = storage_path('medialibrary/temp/' . str_random(16));
     File::makeDirectory($tempDirectory, 493, true);
     Gitignore::createIn(storage_path('medialibrary'));
     return $tempDirectory;
 }
開發者ID:RetinaInc,項目名稱:laravel-medialibrary,代碼行數:12,代碼來源:FileManipulator.php

示例10: fire

 /**
  * Create directory tree for views, and fire the generator.
  */
 public function fire()
 {
     $directoryPath = dirname($this->getFileGenerationPath());
     if (!File::exists($directoryPath)) {
         File::makeDirectory($directoryPath, 0777, true);
     }
     parent::fire();
 }
開發者ID:osura,項目名稱:Laravel-4-Generators,代碼行數:11,代碼來源:ViewGeneratorCommand.php

示例11: checkDirectory

 protected function checkDirectory($namespace, $routePath)
 {
     $rootPath = config('routie.path');
     $routePath = isset($namespace) ? $rootPath . '/' . $routePath : $rootPath;
     if (!File::isDirectory($routePath)) {
         File::makeDirectory($routePath, 0775, true);
     }
     return $routePath;
 }
開發者ID:draperstudio,項目名稱:laravel-routie,代碼行數:9,代碼來源:GenerateRouTie.php

示例12: handle

 /**
  * Handle the event.
  *
  * @param  shopPurchased  $event
  * @return void
  */
 public function handle(shopPurchased $event)
 {
     $payment = $event->payment;
     $shop = $payment->itemable;
     $payment->update(['status' => 1]);
     $shop->update(['status' => 1]);
     File::makeDirectory(public_path() . '/img/files/shop/' . $shop->id, 0775, true, true);
     Addon::shop()->first()->buy();
 }
開發者ID:emadmrz,項目名稱:Hawk,代碼行數:15,代碼來源:activeShop.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $this->validate($request, ['schedule' => 'required', 'category' => 'required', 'type' => 'required']);
     $data = new Item();
     $data->auction_schedule_id = $request->schedule;
     $data->users_id = Auth::user()->id;
     $data->ticket_no = $request->ticket_no;
     $data->category_id = $request->category;
     $data->type_id = $request->type;
     $data->price = $request->price;
     $data->description = $request->description;
     $data->save();
     $item_id = $data->id;
     $destinationPath = 'images/' . Auth::user()->id . '/' . $request->ticket_no;
     File::makeDirectory($destinationPath, 0777, TRUE, TRUE);
     foreach ($request->file('image') as $key => $photo) {
         if ($photo) {
             if ($photo->isValid()) {
                 // original
                 $filename_original = 'image_' . $key . '_original.jpg';
                 Image_::make($photo->getRealPath())->save($destinationPath . '/' . $filename_original);
                 $data = new Image();
                 $data->items_id = $item_id;
                 $data->url = $destinationPath . '/' . $filename_original;
                 $data->save();
                 // for grid view
                 $filename = $destinationPath . '/' . 'image_' . $key . '_349x200.jpg';
                 ph::resize_image($destinationPath . '/' . $filename_original, 349, 200, $filename);
                 $data = new Image();
                 $data->items_id = $item_id;
                 $data->url = $filename;
                 $data->save();
                 // for view page (big)
                 $filename = $destinationPath . '/' . 'image_' . $key . '_725x483.jpg';
                 ph::resize_image($destinationPath . '/' . $filename_original, 725, 483, $filename);
                 $data = new Image();
                 $data->items_id = $item_id;
                 $data->url = $filename;
                 $data->save();
                 // for view page (thumbnail)
                 $filename = $destinationPath . '/' . 'image_' . $key . '_173x126.jpg';
                 ph::resize_image($destinationPath . '/' . $filename_original, 173, 126, $filename);
                 $data = new Image();
                 $data->items_id = $item_id;
                 $data->url = $filename;
                 $data->save();
             } else {
                 Session::flash('message', 'uploaded file is not valid');
                 return redirect('/item');
             }
         }
     }
     Session::flash('message', 'Item with ticket #' . $request->ticket_no . ' was successfully created');
     return redirect('/item');
 }
開發者ID:NavarezCorp,項目名稱:prenda,代碼行數:62,代碼來源:ItemController.php

示例14: extractThumbnail

 /**
  * Move the thumbnail to the specific place
  *
  * @param $thumbnail
  * @param User $user
  * @return string
  */
 private function extractThumbnail($thumbnail, User $user)
 {
     $path = public_path() . '/content/profile_pictures/' . $user->id;
     if (!File::exists($path)) {
         File::makeDirectory($path, 0755, true);
     }
     $thumbnailName = time() . '-' . $thumbnail->getClientOriginalName();
     $thumbnail->move($path, $thumbnailName);
     return $thumbnailName;
 }
開發者ID:elvinmakhmudov,項目名稱:shopping.app,代碼行數:17,代碼來源:Updaterar.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     if (!File::exists('public/upload/images/')) {
         File::makeDirectory('public/upload/images/', 775, true);
     }
     for ($i = 0; $i < 20; $i++) {
         Contact::create(["name" => $faker->name, "phone" => $faker->phoneNumber, "image" => $faker->image('public/upload/images', 200, 200), "user_id" => 1, "sort" => 0]);
     }
 }
開發者ID:kennyfans,項目名稱:blindaiderresearch,代碼行數:15,代碼來源:ContactTableSeeder.php


注:本文中的Illuminate\Support\Facades\File::makeDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。