samedi 30 juillet 2016

Unlink : permission denied (Laravel)

Here, I want to download backup database For that i have user following code in handle() method in console\command.So when i run the command , it should download the backup database. But I'm getting following Error while running the command:

[ErrorException]                                
 unlink(2016-07-30_07-38.sql): Permission denied 

Here is my handle() method code:

 public function handle()
    {
        $date = Carbon::now()->format('Y-m-d_h-i');
        $user = env('DB_USERNAME');
        $password = env('DB_PASSWORD');
        $database = env('DB_DATABASE');
       $command = "mysqldump --user={$user} -p{$password} {$database} > {$date}.sql";        
        $process = new Process($command);
        $process->start();
        while ($process->isRunning()) {
            $public = Storage::disk('public');
            $public->put('acl/' . $date . ".sql", file_get_contents("{$date}.sql"));
            unlink("{$date}.sql");
        }
    }

If anyone found the same problem or have the solution please help me to find it out.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aE6e7l
via IFTTT

Aucun commentaire:

Enregistrer un commentaire