WithFile jpg Problem

When I download a jpg file using withFile, it can not be read when it is unargled. If I directly take the lame directly the project file works perfectly. Please help.

So you want to send a jpg file to the client using the withFile method?

Could you provide us with the code you’re trying to use?

$downloadPath = “edi/temp/”;
$archiveName = “temp.jpg”;
$archive = $this->response->withFile(WWW_ROOT.$downloadPath.$archiveName,[‘name’=>$archiveName,‘download’ =>true]);

return $archive;

This is the code that I use. I use an image that works but after the download, it already gives an error when opening it.

try modify header type:

$this->RequestHandler->respondAs('jpg', ['attachment' => true]);

$this->response->withHeader('Content-type', 'image/jpg');

Thanks, this resolved my problem