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