本文整理汇总了PHP中Storage::makeDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::makeDirectory方法的具体用法?PHP Storage::makeDirectory怎么用?PHP Storage::makeDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::makeDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param StoreMediaRequest $request
* @return Response
*/
public function store(StoreMediaRequest $request)
{
if ($request->ajax()) {
$response = ['error' => 1, 'path' => ''];
if ($request->hasFile('file')) {
$file = $request->file('file');
$folder = '/public/uploads/' . $request->folder;
if (!\Storage::exists($folder)) {
\Storage::makeDirectory($folder);
}
$path = $folder . '/' . date('Y-m-d');
$hashed = sha1(Str::slug($file->getClientOriginalName() . time())) . '.' . $file->getClientOriginalExtension();
if (!\Storage::exists($path)) {
\Storage::makeDirectory($path);
}
if ($file->move(storage_path('app') . $path, $hashed)) {
$path = str_replace('/public', '', $path);
$medium = $this->medium->create(['path' => $path . '/' . $hashed]);
if ($medium) {
$response['error'] = 0;
$response['path'] = $path . '/' . $hashed;
return response($response, 200);
}
// TODO: ln -s storage/app/public/uploads /path/to/public_html/public
}
}
}
return response('error', 400);
}
示例2: checkDirectoryExists
/**
* Checks if the Database Directory exists,
* if not, directory will be created.
*/
private function checkDirectoryExists()
{
$directory = storage_path($this->directoryPath);
if (!$this->storage->exists($directory)) {
$this->storage->makeDirectory($directory);
}
}
示例3: moveToLocalStorage
/**
* @param UploadedFile $file
* @return string
*/
protected function moveToLocalStorage($file)
{
if (!file_exists(storage_path('app/doctor-information'))) {
\Storage::makeDirectory('doctor-information');
}
$disk_filename = Carbon::now()->format('YmdHis') . '.' . $file->getClientOriginalExtension();
$file->move(storage_path('app/doctor-information'), $disk_filename);
return $disk_filename;
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert(['username' => 'aldi.fahrezi', 'fullname' => 'Aldi Fahrezi', 'email' => 'aldi.fahrezi@gmail.com', 'birthday' => '1997-09-08', 'role_id' => 2, 'voted_threads' => "|", 'voted_replies' => "|"]);
for ($count = 0; $count < 5; $count++) {
DB::table('users')->insert(['username' => str_random(10) . $count, 'fullname' => str_random(10) . $count, 'email' => str_random(10) . '@gmail.com', 'birthday' => rand(1611, 2014) . '-' . rand(10, 12) . '-' . rand(10, 30), 'voted_threads' => "|", 'voted_replies' => "|"]);
}
for ($count = 1; $count <= 50; $count++) {
Storage::makeDirectory('users/' . $count);
}
}
示例5: crearCarpeta
private function crearCarpeta()
{
//Si no existe: genera carpeta y obtiene carpeta_id
$carpeta = new Carpeta();
$carpeta->save();
\Storage::makeDirectory($carpeta->id);
//Relacionar Carpeta-Dcoumento
$carpeta_documento = new CarpetaDocumento(['carpeta_id' => $carpeta->id, 'documento_id' => $this->documento_id, 'documento_type' => $this->documento_type]);
$carpeta->documentos()->save($carpeta_documento);
return $carpeta->id;
}
示例6: uploadImage
/**
* Upload image via Image library
*
* @param $file
* @param string $upload_path
* @return string
*/
public function uploadImage($file, $upload_path = '/')
{
$this->setPath($upload_path);
if (!is_dir($this->path)) {
\Storage::makeDirectory($this->path);
}
$this->setFileName($file);
$img = \Image::make($file)->save($this->getPath() . '/' . $this->getFileName(), 100);
$this->fullpath = $this->getPath() . '/' . $this->getFileName();
$this->width = $img->width();
$this->height = $img->height();
return $this->getPath() . '/' . $this->getFileName();
}
示例7: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->packageDir = $this->input['root'] . '/' . $this->input['vendor'] . '/' . $this->input['package'];
$this->modelDir = $this->packageDir . '/src/' . ucfirst($this->input['models']);
$this->model = $this->input['model'];
$this->models = $this->input['models'];
\Storage::makeDirectory($this->packageDir);
$this->recurse_copy(__DIR__ . '/TemplateModel', $this->packageDir);
$this->setFiles();
$this->changeFilenames();
$this->updateFiles($this->input['vendor'], $this->input['package']);
dd('sdsds');
}
示例8: postUploadImage
public function postUploadImage(Request $request, Guard $auth)
{
$pathUser = 'noticias';
\Storage::makeDirectory($pathUser);
$Documento = $request->file('file');
$nombre = $Documento->getClientOriginalName();
$fullPath = $pathUser . '/' . $nombre;
$noticiaImg = NoticiasImg::firstOrNew(['path' => $fullPath]);
$noticiaImg->nombre = $nombre;
$noticiaImg->autor = $auth->id();
$noticiaImg->save();
\Storage::disk('local')->put($fullPath, \File::get($Documento));
return response()->json(['link' => '/documentos/' . $fullPath]);
}
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:14,代码来源:NoticiasController.php
示例9: postCreate
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function postCreate(Request $request)
{
$file = $request->file('avatar')->isValid();
echo $file;
$fileName = $request->input('avatar');
// $slogan = \Request::input('slogan');
// $userInfo = array(
// 'file' => $file,
// 'slogan' => $slogan
// );
//Check if Folder exists
$folderName = date('Ymd');
if (!\Storage::disk('local')->exists($folderName)) {
\Storage::makeDirectory($folderName);
}
//Check Validation
//$fileName = $file->getClientOriginalName();
//Save it to Folder
// \Storage::disk('local')->put($fileName,$file);
// \Storage::move($fileName,$folderName.'/'.$fileName);
// if(\Request::hasFile('avatar')){
// //Check if Folder exists
// $folderName = date('Ymd');
// if(!Storage::disk('local')->exists($folderName)){
// Storage::makeDirectory($folderName);
// }
// //Get input File
// $file = \Request::file('avatar');
// //Check Validation
// $fileName = $file->getClientOriginalName();
// if(!$file->isValid()){
// return [$fileName => 'success'];
// }
// //Save it to Folder
// Storage::disk('local')->put($fileName,$file);
// Storage::move($fileName,$folderName.'/'.$fileName);
// }else{
// echo 'weiba';
// }
/*
$user = \Auth::user();
$validator = Validator::make($userInfo,ValidRule::$phone_login_rules,ValidRule::$phone_login_tips);
if($validator->passes()){
}else{
return \Redirect::to('login')->withErrors($validator);
}
*/
}
示例10: postUploadImage
public function postUploadImage(Request $request, Guard $auth)
{
$postulante = Postulante::where('user_id', $auth->id())->first();
$pathUser = 'testimonios';
\Storage::makeDirectory($pathUser);
$Documento = $request->file('file');
$nombre = $Documento->getClientOriginalName();
$fullPath = $pathUser . '/' . $nombre;
$docAdjunto = DocumentoAdjunto::firstOrNew(['path' => $fullPath]);
$docAdjunto->nombre = $nombre;
$docAdjunto->postulante = $postulante->id;
$docAdjunto->save();
\Storage::disk('local')->put($fullPath, \File::get($Documento));
return response()->json(['link' => '/documentos/' . $fullPath]);
}
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:15,代码来源:TestimonioController.php
示例11: postUploadDocAdmin
public function postUploadDocAdmin(Request $request)
{
$pathUser = 'postulante_' . $request->get("id_postulante") . "/admin";
\Storage::makeDirectory($pathUser);
if ($request->hasFile("cartaF1")) {
$archivo = $request->file('cartaF1');
$temp = "carta de aceptación";
} else {
$archivo = $request->file('cartaF2');
$temp = "Resolución de pregrado";
}
$nombre = \Hash::make($archivo->getClientOriginalName());
$nombre = str_replace('/', 'Y', $nombre);
$nombre = $nombre . '.' . $archivo->guessExtension();
$fullPath = $pathUser . '/' . $nombre;
$docAdjunto = DocumentoAdjunto::firstOrNew(['path' => $fullPath]);
$docAdjunto->nombre = $temp;
$docAdjunto->postulante = $request->get("id_postulante");
$docAdjunto->save();
\Storage::disk('local')->put($fullPath, \File::get($archivo));
}
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:21,代码来源:DocumentosAdjuntosController.php
示例12: upload_photo_on_storage
/**
* Uplaod Image on Storage
*
* @param File $file
* @param $key
*
* @return string
*/
function upload_photo_on_storage(File $file, $key)
{
if (!$file->isValid() || !$key) {
return null;
}
$imageDirectory = 'images/profile';
if (!Storage::has($imageDirectory)) {
Storage::makeDirectory($imageDirectory, 0777);
}
$imageExtension = $file->getClientOriginalExtension();
$imageHashName = $key;
$imageFilePath = "app/{$imageDirectory}/{$imageHashName}";
$imageFileAbsolutePath = storage_path($imageFilePath);
// resize image
$image = Image::make($file->getRealPath())->resize(300, 300, function ($constraint) {
// prevent possible upsizing
$constraint->aspectRatio();
$constraint->upsize();
})->save($imageFileAbsolutePath);
return $image ? $imageFilePath : null;
}
示例13: filehandle
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function filehandle($req, $id)
{
// PDF tidak di update / melalui form
// Gagal mengupload file PDF
// Sukses Mengupload DOkumen
$pesan = ['error' => ['Peringatan : File PDF tidak di atur dengan benar !', 'Terjadi kesalahan upload File PDf '], 'succes' => 'Sukses mengupload Dokumen PDF '];
// dd($req->all());
$file = $req->file('gambar');
// $lokasi_tujuan=str_slug( str_replace('-', ' ', $req->get('no_boks')));
$lokasi_tujuan = $req->get('no_boks');
if ($file and $file->getClientMimeType() == 'application/pdf') {
// dd($file);
$extension = $file->getClientOriginalExtension();
$entry = File::where('dokumen_id', '=', $id)->first();
// format nama file = ==============================================================================================
$nama_file = str_slug(str_replace('/', '-', $req->get('no_sppd'))) . '-' . str_slug(str_replace('/', '-', $req->get('nama_dokumen'))) . '-' . $file->getFilename() . '.' . $extension;
// echo $nama_file;
// dd($entry);
if (count($entry)) {
// dd(count($entry->get()->toArray()));
// $entry=File::find($entry->id);
// dd($entry->with('dokumen')->get());
// dd($entry->get()->toArray()[0]['filename']);
// if (\Storage::exists($entry->get()->toArray()[0]['dir'].'/'.$entry->get()->toArray()[0]['filename'])) {
// \Storage::delete($entry->get()->toArray()[0]['dir'].'/'.$entry->get()->toArray()[0]['filename']);
// }
// if($entry){
$lokasi_baru = $entry->dir . '/' . $entry->nama_baru;
$lokasi_lama = $entry->filename;
if ($entry->dir && $entry->nama_baru && \Storage::exists($lokasi_baru)) {
// echo $lokasi_baru;
\Storage::move($lokasi_baru, 'RecycleBin/' . $entry->nama_baru);
// \Storage::delete($lokasi_baru);
}
if ($entry->filename && \Storage::exists($lokasi_lama)) {
// echo $lokasi_lama;
\Storage::move($lokasi_lama, 'RecycleBin/' . $entry->nama_baru);
// \Storage::delete($lokasi_lama);
}
// dd($lokasi_baru);
// $entry->delete();
// }
$update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $nama_file, 'nama_baru' => $nama_file, 'dir' => $lokasi_tujuan];
if ($entry->update($update)) {
$dirs = \Storage::allDirectories();
// $dir=str_slug( str_replace('-', ' ', $req->get('no_boks')));
$dir = $lokasi_tujuan;
if (!in_array($dir, $dirs)) {
\Storage::makeDirectory($lokasi_tujuan);
}
echo $nama_file;
\Storage::put($dir . '/' . $nama_file, \File::get($file));
return true;
}
return false;
} else {
$entry = new File();
$entry->dokumen_id = $id;
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $nama_file;
$entry->nama_baru = $nama_file;
// $entry->dir = str_slug( $req->get('no_boks'), "-");
$entry->dir = $lokasi_tujuan;
if ($entry->save()) {
$dirs = \Storage::allDirectories();
// $dir=str_slug( str_replace('-', ' ', $req->get('no_boks')));
$dir = $lokasi_tujuan;
if (!in_array($dir, $dirs)) {
\Storage::makeDirectory($lokasi_tujuan);
}
echo $nama_file;
\Storage::put($dir . '/' . $nama_file, \File::get($file));
return true;
}
return false;
}
// }
} else {
// Handle file pdf
//pINDAH DIREKTORI KARENA UPDATE NO BOX
$entry = File::where('dokumen_id', '=', $id)->first();
//JIKA NAMA dir dari file $entry !== str_slug($req->boks)
// $lokasi_tujuan=str_slug( str_replace('-', ' ', $req->get('no_boks')));
if ($entry && $entry->dir !== $lokasi_tujuan) {
$nama_file = str_slug(str_replace('/', '-', $req->get('no_sppd'))) . '-' . str_slug(str_replace('/', '-', $req->get('nama_dokumen'))) . '-' . $entry->filename;
// $nama_file_baru= str_slug( str_replace('-', ' ', $req->get('no_sppd'))).'-'.str_slug( str_replace('-', ' ', $req->get('nama_dokumen'))).'-'.$entry->filename;
// $entry->nama_baru=!empty($entry->nama_baru) ? $entry->nama_baru:str_replace('/', '-', $entry->dokumen->no_sppd).'-'.$entry->filename;
$entry->nama_baru = !empty($entry->nama_baru) ? $entry->nama_baru : $nama_file;
// $entry->nama_baru=str_replace('/', '-', $entry->dokumen->no_sppd).'-'.$entry->filename;
// dd('lama masuk ');
$lokasi_lama_file = $entry->dir . '/' . $entry->nama_baru;
$lokasi_lama_lama_migrasi = $entry->filename;
//.........这里部分代码省略.........
示例14: save
/**
* guarda un archivo en nuestro directorio local.
*
* @return Response
*/
public function save(Request $request)
{
// dd(Session::get('dni'));
//obtenemos el campo file definido en el formulario
\Storage::makeDirectory(Session::get('dni'), 0777);
$file1 = $request->file('file1');
if ($file1 != null) {
//obtenemos el nombre del archivo
$nombre = Session::get('dni') . "/" . $file1->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre, \File::get($file1));
}
//obtenemos el campo file definido en el formulario
$file2 = $request->file('file2');
if ($file2 != null) {
//obtenemos el nombre del archivo
$nombre = Session::get('dni') . "/" . $file2->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre, \File::get($file2));
}
//obtenemos el campo file definido en el formulario
$file3 = $request->file('file3');
if ($file3 != null) {
//obtenemos el nombre del archivo
$nombre = Session::get('dni') . "/" . $file3->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre, \File::get($file3));
}
Session::forget('dni');
Session::flash('file_success', 'Los archivos fueron enviados correctamente!');
Session::flash('alert-class', 'alert-success');
return redirect()->back();
}
示例15: postStorageFiles
public function postStorageFiles(Request $request, Guard $auth)
{
/* $postulante = Postulante::where('user_id',$auth->id())->first();
$Documentos = $request->file('documentosAdjuntos');
$count = 0;
$destino_path = public_path().'\documentos\postulante_'.$postulante->id;
foreach($Documentos as $archivo) {
$url_imagen = \Hash::make($archivo->getClientOriginalName());
$path_file = $url_imagen.'.'.$archivo->guessExtension();
//$path_file = str_replace('/', '0', $path_file);
$subir = $archivo->move($destino_path, $destino_path);
dd($path_file);
//dd($url_imagen.'__________'.$path_file);
$nombre_input = $request->get('new_'.$count);
$docAdjunto = DocumentoAdjunto::firstOrNew(['nombre' => $nombre_input,'postulante'=>$postulante->id]);;
$docAdjunto->path = $path_file;
$docAdjunto->save();
$count++;
}
return response()->json([
'message'=> 'Conexión realizada ctm'
]);*/
$postulante = Postulante::where('user_id', $auth->id())->first();
$pathUser = 'postulante_' . $postulante->id;
\Storage::makeDirectory($pathUser);
$Documentos = $request->file('documentosAdjuntos');
$count = 0;
foreach ($Documentos as $archivo) {
$nombre = \Hash::make($archivo->getClientOriginalName());
$nombre = str_replace('/', 'Y', $nombre);
$nombre = $nombre . '.' . $archivo->guessExtension();
$nombre_input = $request->get('new_' . $count);
$fullPath = $pathUser . '/' . $nombre;
$docAdjunto = DocumentoAdjunto::firstOrNew(['path' => $fullPath]);
$docAdjunto->nombre = $nombre_input;
$docAdjunto->postulante = $postulante->id;
$docAdjunto->save();
\Storage::disk('local')->put($fullPath, \File::get($archivo));
$count++;
}
return response()->json(['message' => 'Conexión realizada ctm']);
}
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:54,代码来源:DocumentosPostulacionController.php