Sunday, March 11, 2018

Deleting a file in Laravel cause an exception - development

Deleting a file in Laravel cause an exception

i am trying to delete a file in laravel but it is causing this exception:

unlink(D:graduation projectkhstorageappupload/three.zip): Resource temporarily unavailable in D:graduation projectkhvendorleagueflysystemsrcAdapterLocal.php

before trying to delete the file i checked if it exists, checking returned a true value.
here is my piece of code in the controller:

protected function saveFile(UploadedFile $file)
    {
        $zip = new Zipper;
        $fileName = $this->createFilename($file);

        $finalPath = storage_path().'/app/upload/';

        // move the file name
        $file->move($finalPath, $fileName);
        $zip->make($finalPath.$fileName)->extractTo($finalPath);
        $exist = Storage::disk('local')->exists('/upload/'.$fileName);
        if($exist){
           Storage::delete('/upload/'.$fileName)//i get the error here; 
        }



        return response()->json([
            'path' => $finalPath,
            'name' => $fileName,
            'exist' => $exist
        ]);
    }

and this is the response i get, it shows that the file exists (Note: when i took this image i commented the deletion line): response



from Laravel Questions and Answers https://laravelquestions.com/laravel/deleting-a-file-in-laravel-cause-an-exception/
via Lzo Media

No comments:

Post a Comment