file = $file; $this->directory = $directory; } public function handle(): ?string { $tmp_file = sha1(time()).'.png'; $im = imagecreatefromstring(file_get_contents($this->file)); imagealphablending($im, false); imagesavealpha($im, true); $file_png = imagepng($im, sys_get_temp_dir().'/'.$tmp_file); $path = Storage::putFile($this->directory, new File(sys_get_temp_dir().'/'.$tmp_file)); $url = Storage::url($path); //return file path if ($url) { return $url; } else { return null; } } }