Serving Images to get a request

喜夏-厌秋 提交于 2019-12-02 07:52:37

To make CodeIgniter set the proper headers and such you could do this in your controller:

$this->output->set_content_type('jpeg')->set_output(file_get_contents('path_to_file'));

And it will output (as request response) the image content as a file. No view required.

Please note though that this is a bit of extra overhead as the file is processed by PHP instead of just the webserver (Apache/Nginx). It only makes sense if you need to have some business logic on the request, such as logging or authorization (though even that can be done without PHP). If you are just outputing the image it is therefor better to link straight to file and leave PHP out of it.

I think You could show the images to client and give them a check-boxes to download the images as a Zip file.

See this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!