Upload file to BackBlaze

224 Views Asked by At

I have a form with 2 file inputs and I need to choose a file and upload it to backblaze. This is the function that I created in order to upload the picture. I pass as a parameter the path that I retrieved from the form.

public function uploadImage($path)
    {
        try {
            //get file name
            $fileName = $path->getClientOriginalName();

            // get file contents
            $contents = file_get_contents($path->getRealPath());

            //upload to Backblaze
            Storage::disk('b2')->put($fileName, $contents);
            dd('OK! STORED SUCESSFULLY');
        } catch (\Throwable $e) {
            dd($e);
        }
    }

I got the next error

ErrorException {#2033 ▼ // app\Http\Livewire\quote\NewQuote.php:89
  #message: "filesize(): Filename contains null byte"
  #code: 0
  #file: "C:\Users\Usuario\Desktop\Dev\CRM\vendor\marcandreappel\flysystem-backblaze\src\BackblazeAdapter.php"
  #line: 45
  #severity: E_WARNING
  trace: {▶}
}
0

There are 0 best solutions below