本文整理汇总了PHP中Storage::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::exists方法的具体用法?PHP Storage::exists怎么用?PHP Storage::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($token)
{
$env = Environment::where('token', $token)->first();
if (is_null($env)) {
return json_encode(['error' => true, 'output' => 'invalid token']);
}
if (\Storage::exists($token . '.php')) {
$tokenFile = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . "/" . $token . ".php";
$output = null;
$error = false;
foreach ($this->steps as $step) {
$command = "dep --ansi --file={$tokenFile} {$step} " . $env->server->host;
$output .= $command . "\n";
$process = new Process($command);
$process->run();
if (!$process->isSuccessful()) {
$output .= $process->getErrorOutput();
$error = true;
break;
} else {
$output .= $process->getOutput();
}
}
$history = EnvironmentHistory::create(['environment_id' => $env->id, 'status' => $error ? 'fail' : 'success', 'history' => $output]);
return json_encode(['error' => $error, 'output' => $output]);
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// If DB file exists delete it
if (Storage::exists(database_path('SPGProfileDB.sqlite'))) {
Storage::delete(database_path('SPGProfileDB.sqlite'));
}
Schema::connection($this->TargetDB)->drop('pass_profiles');
}
开发者ID:Dev1436,项目名称:laravel-securepassgen,代码行数:13,代码来源:2015_12_12_012546_create_pass_profiles_table.php
示例5: getImg
private static function getImg(Meeting $meeting)
{
$name = 'meetings/' . $meeting->id;
if (!\Storage::exists($name)) {
return false;
}
return \Storage::get($name);
}
示例6: delete
public function delete($projectId, $id)
{
try {
$projectFile = $this->repository->find($id);
if ($this->storage->exists($projectFile->getFileName())) {
$this->storage->delete($projectFile->getFileName());
}
$this->repository->delete($id);
return ['success' => true, "message" => 'Registro excluído com sucesso.'];
} catch (ModelNotFoundException $e) {
return ['error' => true, 'message' => 'Registro não encontrado.', "messageDev" => $e->getMessage()];
} catch (QueryException $e) {
return ['error' => true, 'message' => 'Este registro não pode ser excluído, pois existe um ou mais projetos vinculados a ele.', "messageDev" => $e->getMessage()];
} catch (\Exception $e) {
return ["error" => true, "message" => 'Falha ao excluir registro.', "messageDev" => $e->getMessage()];
}
}
示例7: verfoto
public function verfoto(Request $request)
{
$public_path = public_path();
//$url = $public_path.'/storage/'.$request->archivo;
$url = \Storage::disk('local') . $request->archivo;
//verificamos si el archivo existe y lo retornamos
if (Storage::exists($archivo)) {
return response()->download($url);
}
//si no se encuentra lanzamos un error 404.
abort(404);
}
示例8: setContent
public function setContent($content = null)
{
if ($content == null || !is_array($content)) {
$content = $this->getContent();
}
$this->content = $content;
\Storage::put($this->file_directory . '/' . $this->file_name . '-' . $this->id . '.json', json_encode($this->content));
if (\Storage::exists($this->file_directory . '/' . $this->file_name . '.json')) {
\Storage::delete($this->file_directory . '/' . $this->file_name . '.json');
}
\Storage::copy($this->file_directory . '/' . $this->file_name . '-' . $this->id . '.json', $this->file_directory . '/' . $this->file_name . '.json');
return $this->content;
}
示例9: get
public function get($id)
{
// $entry = File::where('filename', '=', $filename)->firstOrFail();
// $file = \Storage::disk('local')->get($entry->filename);
// // return (new \Response($file, 200))
// // ->header('Content-Type', $entry->mime);
// return response($file,200)
// ->header('Content-Type', $entry->mime);
// ===============================================================================================
// $entry = File::where('filename', '=', $filename)->firstOrFail();
// if (\Storage::exists($entry->filename)) {
// $file = \Storage::disk('local')->get($entry->filename);
// // return (new \Response($file, 200))
// // ->header('Content-Type', $entry->mime);
// return response($file,200)
// ->header('Content-Type', $entry->mime);
// }
// else{
// return 'File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
// }
$entry = File::find(base64_decode($id));
// dd($entry);
if ($entry) {
$dirfile = empty($entry->nama_baru) ? $entry->filename : $entry->dir . '/' . $entry->nama_baru;
// echo $dirfile;
// ARSIPPROSESSP2D-UYUYphpFDCC.tmp.pdf
// dinas-p/ARSIPPROSESSP2D-UYUYphpF441.tmp.pdf
// dd($dirfile);
// dd($dirfile);
// "SEKWAN-II/164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-phpCAC5.tmp.pdf";
// "164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-1-php757E.tmp"
if (\Storage::exists($dirfile)) {
$file = \Storage::get($dirfile);
// return (new \Response($file, 200))
// ->header('Content-Type', $entry->mime);
return response($file, 200)->header('Content-Type', $entry->mime);
} elseif (!empty($entry->filename) && \Storage::exists($entry->filename)) {
$file = \Storage::get($entry->filename);
// return (new \Response($file, 200))
// ->header('Content-Type', $entry->mime);
return response($file, 200)->header('Content-Type', $entry->mime);
} else {
return 'File tidak ditemukan, Silahkan Update Ulang ';
}
} else {
return 'Data File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
}
}
示例10: get
public function get($filename, $size = null)
{
// Cut original file name
$file = explode('.', $filename);
$file_path = '';
if (empty($filename)) {
return '';
}
if (empty($size) && \Storage::exists($this->basepath . $file[0] . '_L.' . $file[1])) {
$file_path = $this->basepath . $file[0] . '_L.' . $file[1];
} else {
if (\Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
$file_path = $this->basepath . $file[0] . '_' . $size . '.' . $file[1];
} else {
$file_path = $this->basepath . $filename;
}
}
return url($file_path);
}
示例11: get
public function get($filename, $size = null)
{
if (empty($filename)) {
return '';
}
// Cut original file name
$file = explode('.', $filename);
$file_path = '';
if (empty($filename)) {
return '';
}
if (empty($size) && \Storage::exists($this->basepath . $file[0] . '_L.' . $file[1])) {
$file_path = $this->basepath . $file[0] . '_L.' . $file[1];
} elseif (\Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
$file_path = $this->basepath . $file[0] . '_' . $size . '.' . $file[1];
} else {
$file_path = $this->basepath . $filename;
}
if (\Config::get('filesystems.default') == 's3') {
return \Storage::getDriver()->getAdapter()->getClient()->getObjectUrl(\Storage::getDriver()->getAdapter()->getBucket(), $this->basepath . $filename);
} else {
return url($file_path);
}
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$data_dokumen = Dokumens::find($id);
$data_dokumen_pesan = $data_dokumen;
// dd($data_dokumen_pesan->nama_skpd);
if ($data_dokumen) {
$data_dokumen->delete();
$file = $data_dokumen->file;
// dd($file);
// $file->get()['filename'];
if ($file) {
$lokasi_baru = $file->dir . '/' . $file->nama_baru;
$lokasi_lama = $file->filename;
if ($file->nama_baru && $file->dir && \Storage::exists($lokasi_baru)) {
# code...
// echo $lokasi_baru;
\Storage::move($lokasi_baru, 'RecycleBin/' . $file->nama_baru);
}
if (\Storage::exists($lokasi_lama)) {
// echo $lokasi_lama;
\Storage::move($lokasi_lama, 'RecycleBin/' . $file->filename);
# code...
}
// $file->delete();
}
}
$data_dokumenx = Dokumens::find($id);
if (!$data_dokumenx) {
return 'Sukses data SPPD ' . $data_dokumen_pesan->no_sppd;
} else {
return 'gagal data SPPD ' . $data_dokumen_pesan->no_sppd;
}
// return __function__;
//
}
示例13:
<th>TAMAÑO</th>
<th>CREADO</th>
<th>ACCION</th>
</tr>
</thead>
<tbody>
@foreach($medios as $medio)
<tr>
<td>{{ $medio->id }}</td>
<td>
<a href="/medios/{{ $medio->nombre}}" target="newwindow"
data-toggle="tooltip" data-placement="right"
title="PRESIONE CLICK PARA VER O DESCARGAR SEGUN SEA EL TIPO DE ARCHIVO">
<?php
if (Storage::exists($medio->nombre)) {
$nombre = $medio->nombre;
$tamanio = Storage::size($medio->nombre);
$creado = $medio->created_at;
$tipo = $medio->tipo;
if ($tipo == 'jpg' || $tipo == 'png' || $tipo == 'jpeg' || $tipo == 'gif') {
?>
<img class="img_click" src="/medios/{{ $medio->nombre}}"><?php
} else {
if ($tipo == 'pdf') {
?>
<img class="img_click" src="/img/pdf.png"><?php
} else {
if ($tipo == 'doc' || $tipo == 'dot' || $tipo == 'docx') {
?>
<img class="img_click" src="/img/m_word.png"><?php
示例14: getLoginOk
public function getLoginOk($wxuin)
{
$file = "user/{$wxuin}.txt";
if (\Storage::exists($file)) {
$user = \Storage::get($file);
$user = json_decode($user);
} else {
return '不存在此wxuin';
}
//进行post登陆尝试
$url = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?lang=zh_CN&pass_ticket=" . urlencode($user->pass_ticket) . "&r=-" . rr();
$post = '{"BaseRequest":{"Uin":"' . $user->cookies->wxuin . '","Sid":"' . $user->cookies->wxsid . '","Skey":"' . $user->skey . '","DeviceID":"' . $user->deviceid . '"}}';
$ret = CURL::send($url, ['Cookie' => urldecode(http_build_query($user->cookies, '', '; '))], ['follow_redirects' => false], ['ret' => 'all', 'post' => $post]);
$cookies = toCookies($ret->cookies);
$cookies = (object) ((array) $cookies + (array) $user->cookies);
//判断是否正常
$data_arr = json_decode($ret->body, true);
if (count($data_arr)) {
if (!isset($data_arr['BaseResponse']['Ret'])) {
$data_arr = array();
} else {
if ($data_arr['BaseResponse']['Ret'] != 0) {
return $data_arr['BaseResponse']['Ret'] . $data_arr['BaseResponse']['ErrMsg'] . ',请从新<a href="/login/">扫描</a>';
}
}
} else {
return '没有获取到内容,请从新<a href="/login/">扫描</a>';
}
//开始获取基本信息了
$data['Uin'] = $data_arr['User']['Uin'];
$data['UserName'] = $data_arr['User']['UserName'];
$data['NickName'] = $data_arr['User']['NickName'];
$data['SyncKey'] = json_encode($data_arr['SyncKey']);
$data['wxuin'] = $cookies->wxuin;
$data['skey'] = urldecode($user->skey);
$data['pass_ticket'] = urldecode($user->pass_ticket);
$data['deviceid'] = $user->deviceid;
$data['cookies'] = json_encode($cookies);
//设置状态为可用
$data['status'] = 1;
Login::inSave($data);
//删除临时文件
\Storage::delete($file);
//写入好友信息
$this->ContactList($data_arr);
//加入群信息获取队列
$job = (new JobChatroom($data['wxuin']))->onQueue('chatroom');
$this->dispatch($job);
//加入监控队列
$job = (new JobCheck($data['wxuin']))->onQueue('check');
$this->dispatch($job);
}
示例15: removeFile
public function removeFile($filename, Flash $flash)
{
$file = "{$filename}.pdf";
if (\Storage::exists($file)) {
\Storage::delete($file);
$flash->success('File has been deleted.');
}
return redirect()->back();
}