本文整理匯總了PHP中Illuminate\Support\Facades\File::isWritable方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::isWritable方法的具體用法?PHP File::isWritable怎麽用?PHP File::isWritable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::isWritable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: upload
public function upload($path, $filename, $file)
{
// Verifica se o diretório permite escrita
if (!File::isWritable(storage_path('app/' . $path))) {
return ['cod' => '0', 'msg' => '[ERRO] Diretorio sem permissão de escrita.'];
}
if (Storage::exists('app/' . $path . '/' . $filename)) {
return ['cod' => '0', 'msg' => '[ERRO] Já existe um arquivo com este nome.'];
}
return Storage::disk('local')->put($path . $filename, file_get_contents($file->getRealPath()));
}
示例2: checkPathIsOk
private function checkPathIsOk($path, $dir = null)
{
$path = rtrim($path, '/') . ($dir ? '/' . trim($dir, '/') : '');
if (File::isDirectory($path) && File::isWritable($path)) {
return true;
} else {
try {
@File::makeDirectory($path, 0777, true);
return true;
} catch (\Exception $e) {
Log::error('Uploader: ' . $e->getMessage());
$this->results['error'] = $e->getMessage();
return false;
}
}
}
示例3: generateFile
protected function generateFile($code)
{
if (!File::isDirectory($this->path)) {
File::makeDirectory($this->path);
}
if (File::isWritable($this->path)) {
if (!File::isDirectory($this->path . $this->pathfile)) {
File::makeDirectory($this->path . $this->pathfile);
}
if (File::isWritable($this->path . $this->pathfile)) {
File::put($this->filename, $code);
if (File::exists($this->filename)) {
return "File " . $this->filename . " created successfully";
} else {
return "no se pudo crear " . $this->filename;
}
}
return "No se puede escribir o no existe " . $this->path . $this->pathfile;
}
return "No se puede escribir o no existe " . $this->path;
}
示例4: setup
/**
* Perform necessary checks
* @return boolean
* @throws \RuntimeException
*/
public function setup()
{
// Check if files directory has been created
if (!File::isDirectory($this->config['filePath'])) {
throw new \RuntimeException('It looks like config file has not been published. Use php artisan config:publish command.');
}
// Check if files directory has been created
if (!File::isWritable($this->config['filePath'])) {
throw new \RuntimeException('Please make sure that files directory is writable.');
}
// initialized fileNumber with database on first run
if (!Schema::hasTable($this->config['filenum_table']['tableName'])) {
$this->createTable($this->config['filenum_table']);
FileNumber::create(array($this->config['filenum_table']['fieldName'] => $this->config['fileNumber']));
$this->config['header_record']['header_bath_number'] = $this->padWithZero();
$this->config['fileName'] .= $this->padWithZero() . '.tmp';
$this->setFileNumber();
} else {
$this->setFileName();
}
// initialized dr_consignment_number with database on first run
if (!Schema::hasTable($this->config['consnum_table']['tableName'])) {
$this->createTable($this->config['consnum_table']);
ConsNumber::create(array($this->config['consnum_table']['fieldName'] => $this->config['dr_consignment_number']['number']));
} else {
$this->getConsignmentNumber();
}
/**
* Set header type to SKEL
* Allowing UK Domestic services despatches only
*
* config default: DSCC - UK Domestic collection request
*/
if ($this->config['header_record']['header_file_type'] === 'SKEL') {
$this->config['deliveryDetails']['dr_location_id'] = 1;
}
return true;
}
示例5: getUploadFolder
/**
* Get upload path with date folders
* @param $date
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
* @throws \Doctrine\Common\Proxy\Exception\InvalidArgumentException
* @return string
*/
public function getUploadFolder($date = null)
{
// Check that a date was given
if (is_null($date)) {
$date = Carbon::now();
} elseif (!is_a($date, 'Carbon')) {
throw new InvalidArgumentException('Must me a Carbon object');
}
// Get the configuration value for the upload path
$path = static::$app['config']->get('cabinet::upload_folder');
$path = $this->cleanPath($path);
// Add the project base to the path
$path = static::$app['path.base'] . $path;
$this->dateFolderPath = str_replace('-', '/', $date->toDateString()) . '/';
// Parse in to a folder format. 2013:03:30 -> 2013/03/30/{filename}.jpg
$folder = $path . $this->dateFolderPath;
// Check to see if the upload folder exists
if (!File::exists($folder)) {
// Try and create it
if (!File::makeDirectory($folder, static::$app['config']->get('cabinet::upload_folder_permission_value'), true)) {
throw new FileException('Directory is not writable. Please make upload folder writable.');
}
}
// Check that the folder is writable
if (!File::isWritable($folder)) {
throw new FileException('Folder is not writable.');
}
return $folder;
}