本文整理汇总了PHP中File::isDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP File::isDirectory方法的具体用法?PHP File::isDirectory怎么用?PHP File::isDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::isDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadImage
public static function uploadImage($user_id)
{
$error_code = ApiResponse::OK;
if (User::where('user_id', $user_id)->first()) {
$profile = Profile::where('user_id', $user_id)->first();
if (Input::hasFile('file')) {
$file = Input::file('file');
$destinationPath = public_path() . '/images/' . $user_id . '/avatar';
$filename = date('YmdHis') . '_' . $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
if (!File::isDirectory($destinationPath)) {
File::makeDirectory($destinationPath, $mode = 0777, true, true);
}
$upload_success = $file->move($destinationPath, $filename);
$profile->image = 'images/' . $user_id . '/avatar/' . $filename;
$profile->save();
$data = URL::asset($profile->image);
} else {
$error_code = ApiResponse::MISSING_PARAMS;
$data = null;
}
} else {
$error_code = ApiResponse::UNAVAILABLE_USER;
$data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_USER);
}
return array("code" => $error_code, "data" => $data);
}
示例2: simpan
function simpan($id)
{
if ($this->getCount($id) > 6) {
echo "not";
} else {
$pajak = new Pajak();
$pajak->id_pengadaan = $id;
$pajak->jenis_pajak = Input::get('jenis_pajak');
$pajak->no_pajak = Input::get("no_pajak");
$pajak->tgl_pajak = date('Y-m-d', strtotime(Input::get('tanggal')));
$pajak->save();
$id_pajak = $pajak->id_pajak;
if (!File::isDirectory(public_path() . '/asset/img/pajak/' . $id)) {
File::makeDirectory(public_path() . '/asset/img/pajak/' . $id);
}
$filenpwp = Input::file('file_npwp');
$newnpwp = $id . '_' . $id_pajak . '.' . $filenpwp->guessClientExtension();
Image::make($filenpwp->getRealPath())->save(public_path('/asset/img/pajak/' . $id . '/' . $newnpwp));
$data = Pajak::find($id_pajak);
$data->file_pajak = $newnpwp;
if ($data->save()) {
echo "ok";
} else {
echo "error";
}
}
}
示例3: upload
/**
* @param $file
* @return array
*/
public function upload($file)
{
if (!$file->getClientOriginalName()) {
return ['status' => false, 'code' => 404];
}
$destinationPath = public_path() . $this->imgDir;
$fileName = $file->getClientOriginalName();
$fileSize = $file->getClientSize();
$ext = $file->guessClientExtension();
$type = $file->getMimeType();
$upload_success = Input::file('file')->move($destinationPath, $fileName);
if ($upload_success) {
$md5_name = md5($fileName . time()) . '.' . $ext;
$_uploadFile = date('Ymd') . '/' . $md5_name;
if (!File::isDirectory($destinationPath . date('Ymd'))) {
File::makeDirectory($destinationPath . date('Ymd'));
}
// resizing an uploaded file
Image::make($destinationPath . $fileName)->resize($this->width, $this->height)->save($destinationPath . $_uploadFile);
File::delete($destinationPath . $fileName);
$data = ['status' => true, 'code' => 200, 'file' => ['disk_name' => $fileName, 'file_name' => $md5_name, 'type' => $type, 'size' => $fileSize, 'path' => $this->imgDir . $_uploadFile]];
return $data;
} else {
return ['status' => false, 'code' => 400];
}
}
示例4: setUp
public function setUp()
{
parent::setUp();
if (File::isDirectory('packages')) {
File::deleteDirectory('packages');
}
}
示例5: execute
/**
* Executes a program and returns the return code.
* Output from command is logged at INFO level.
* @return int Return code from execution.
*/
public function execute()
{
// test if os match
$myos = Phing::getProperty("os.name");
$this->log("Myos = " . $myos, PROJECT_MSG_VERBOSE);
if ($this->os !== null && strpos($os, $myos) === false) {
// this command will be executed only on the specified OS
$this->log("Not found in " . $os, PROJECT_MSG_VERBOSE);
return 0;
}
if ($this->dir !== null) {
if ($this->dir->isDirectory()) {
$currdir = getcwd();
@chdir($this->dir->getPath());
} else {
throw new BuildException("Can't chdir to:" . $this->dir->__toString());
}
}
if ($this->escape == true) {
// FIXME - figure out whether this is correct behavior
$this->command = escapeshellcmd($this->command);
}
if ($this->error !== null) {
$this->command .= ' 2> ' . $this->error->getPath();
$this->log("Writing error output to: " . $this->error->getPath());
}
if ($this->output !== null) {
$this->command .= ' 1> ' . $this->output->getPath();
$this->log("Writing standard output to: " . $this->output->getPath());
} elseif ($this->spawn) {
$this->command .= ' 1>/dev/null';
$this->log("Sending ouptut to /dev/null");
}
// If neither output nor error are being written to file
// then we'll redirect error to stdout so that we can dump
// it to screen below.
if ($this->output === null && $this->error === null) {
$this->command .= ' 2>&1';
}
// we ignore the spawn boolean for windows
if ($this->spawn) {
$this->command .= ' &';
}
$this->log("Executing command: " . $this->command);
$output = array();
$return = null;
exec($this->command, $output, $return);
if ($this->dir !== null) {
@chdir($currdir);
}
foreach ($output as $line) {
$this->log($line, $this->passthru ? PROJECT_MSG_INFO : PROJECT_MSG_VERBOSE);
}
if ($return != 0 && $this->checkreturn) {
throw new BuildException("Task exited with code {$return}");
}
return $return;
}
示例6: prepare
protected static function prepare($type)
{
$path = storage_path('logs/wechat');
$file = $path . '/' . $type . '-' . date('Y-m-d') . '.log';
if (!\File::isDirectory($path)) {
\File::makeDirectory($path);
}
return $file;
}
示例7: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->setReplacement();
$this->setSetting();
if (!\File::isDirectory($this->getStorageDirectory())) {
\File::makeDirectory($this->getStorageDirectory());
$this->makeCrudForm();
}
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->setReplacement();
if (!\File::isDirectory($this->storageDirectory)) {
\File::makeDirectory($this->storageDirectory);
}
$this->makeBaseRepo();
$this->makeModelRepo();
$this->comment(PHP_EOL . 'CRUDED IT' . PHP_EOL);
}
示例9: getExistingBillTemplates
/**
* Get Existing Bill Templates
*/
protected function getExistingBillTemplates()
{
$path = __DIR__ . '/../../../../';
$billsTypes = \File::allFiles($path . "resources/components/bills");
$customPath = base_path() . '/resources/views/bills';
$customBillTypes = \File::isDirectory($customPath) ? \File::allFiles($customPath) : [];
foreach (array_merge($billsTypes, $customBillTypes) as $billFile) {
app('veer')->loadedComponents['billsTypes'][array_get(pathinfo($billFile), 'filename')] = array_get(pathinfo($billFile), 'filename');
}
}
示例10: make_controller
function make_controller($controller, $method)
{
$content = "<?php\n\nclass {$controller} extends BaseController\n{\n /**\n * 初始化\n * @return void\n */\n public function __construct()\n {\n parent::__construct();\n }\n\n /**\n * 页面:默认\n * @return Response\n */\n public function {$method}()\n {\n return __FILE__;\n }\n}\n";
$array = explode('_', $controller);
$fileName = array_pop($array) . '.php';
$path = app_path('controllers/' . implode('/', $array) . '/');
// 若目录不存在,则递归创建
File::isDirectory($path) or File::makeDirectory($path, 0777, true);
// 创建文件
File::put($path . '/' . $fileName, $content);
}
示例11: assets
public function assets($file = null)
{
if (!is_null($file) && \File::isDirectory($this->themesAssetsPath)) {
if (!\File::exists($this->themesAssetsPath . $file)) {
return \Response::make("Not found!", 404);
}
$requestedFile = \File::get($this->themesAssetsPath . $file);
return \Response::make($requestedFile, 200, array('Content-Type' => $this->mimeMap[\Str::lower(\File::extension($this->themesAssetsPath . $file))]));
}
return \Redirect::route('app.home');
}
示例12: fire
public function fire()
{
if (!$this->option('verbose')) {
$this->output = new NullOutput();
}
if (\File::isDirectory($indexPath = Config::get('laravel-lucene-search.index.path'))) {
\File::deleteDirectory($indexPath);
$this->info('Search index is cleared.');
} else {
$this->comment('There is nothing to clear..');
}
}
示例13: prepareDirectories
/**
* Create directories necessary for backup process
*/
private function prepareDirectories()
{
if (!File::isDirectory($this->userFolderPath)) {
File::makeDirectory($this->userFolderPath, 0775);
}
if (!File::isDirectory($this->userFolderPath . '/files')) {
File::makeDirectory($this->userFolderPath . '/files', 0775);
}
if (!File::isDirectory($this->userFolderPath . '/zip')) {
File::makeDirectory($this->userFolderPath . '/zip', 0775);
}
}
示例14: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
// Create certs dir if it doesn't exist
if (!File::isDirectory('/data/certs')) {
File::makeDirectory('/data/certs');
}
// Touch sqlite database file
if (!File::exists('/data/trusted.sqlite')) {
File::put('/data/trusted.sqlite', '');
$this->call('migrate', ['--seed' => true, '--force' => true]);
}
}
示例15: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$dir = storage_path('backup');
if (!\File::isDirectory($dir)) {
\File::makeDirectory($dir);
}
$command = sprintf('mysqldump %s > %s -u%s -p%s', $this->option('db'), storage_path("backup/{$this->option('db')}.sql"), $this->argument('user'), $this->argument('pass'));
system($command);
$now = \Carbon\Carbon::now()->toDateTimeString();
$result = "{$this->getName()} command done at {$now}";
\Log::info($result);
return $this->info($result);
}