![]() |
1. You don't need to call the send() method. At least if you don't know how it works and what consequences it will cause.
2. The solution to your case will be in version 4.4. 3. To display the file in the browser, the header "Content-Disposition: inline" is needed. But in the current implementation, this header will be overwritten. The easiest TEMPORARY solution for you would be... 1. Take the DownloadResponse class from the repository from the 4.4 branch (https://github.com/codeigniter4/CodeIgni...sponse.php) 2. Save the file in the application directory app/DownloadResponse.php 3. In the file, change the namespace from "CodeIgniter\HTTP" to "App". 4. Next, in the controller method, call the following code. PHP Code: (new \App\DownloadResponse('1.webp', true))->setFilePath(ROOTPATH . 'private/1.webp')->inline()->send(); I haven't tested it, but in theory it should work. When you upgrade to version 4.4, use the ready-made solution described in the documentation. And without calling send() and exit(). |
Messages In This Thread |
Return Image to the Browser from Private Folder - by amit - 07-21-2023, 11:05 AM
RE: Return Image to the Browser from Private Folder - by iRedds - 07-21-2023, 09:46 PM
RE: Return Image to the Browser from Private Folder - by amit - 07-22-2023, 09:57 AM
|