0

While Updating an image after cropping, I am getting the following error:

Symfony\Component\HttpFoundation\File\UploadedFile::__construct(): Argument #5 ($test) must be of type bool, null given

        $croppedimage = $request->croppedimage;
        $baseurl = url('')."/";
        $tempfile = Str::replace($baseurl, "", $croppedimage);
        $sizeFile = \File::size($tempfile);
        $originalName = pathinfo($croppedimage, PATHINFO_BASENAME);
        $p = new UploadedFile($tempfile, $originalName, 'image/jpeg', $sizeFile, null, TRUE);
  • 2
    What part of the error is unclear to you? It says `Argument #5 ($test) must be of type bool, null given` and glancing at the code we can immediately see that you've specifically provided `null` (hard-coded) as the 5th argument to the UploadedFile constructor: `new UploadedFile($tempfile, $originalName, 'image/jpeg', $sizeFile, null, TRUE);`. The error says you can't do that, you must provide a boolean value (i.e. `true` or `false`). Consult the documentation of this class, and then decide, for your scenario, which of true or false is the better value to send, in order to achieve what you want. – ADyson Feb 10 '23 at 11:34

0 Answers0