本文整理匯總了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;
}
示例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);
}
}
示例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');
}
示例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);
}
}
示例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;
}
示例6: checkSharedFolderExists
private function checkSharedFolderExists()
{
$path = $this->getPath('share');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
}
示例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;
}
}
示例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());
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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');
}
示例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;
}
示例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]);
}
}