FPDF error: Missing or incorrect image file

亡梦爱人 提交于 2019-11-29 08:33:58
Siva

After a long struggle finally I found the reason for this issue which I've already discussed here.

Mainly this problem is due to the 'allow_url_fopen' setting which is not enabled for my server, I've solved this issue by using the CURL. I'm giving the step by step procedure to solve this issue because this may useful for somebody like me to avoid wastage of time(for finding the solution).

1. Create a temporary file in the local system with write permission.

Ex: $fp = @fopen($local_file_path, 'x'); 
    fclose($fp);

2. Get the remote location file contents using CURL and write that to local file 
which is created in the previous step.

Ex: $curl = new CurlWrapper($remote_file_path);
    $curl->copyToFile($local_file_path);

3. Now send this local file path to FPDF function(image) then the corresponding 
PDF will get generate for the file without any issues.

I think this is one method to solve this issue, if anybody knows some other ways then you can post them here so that this question may be useful for somebody.

just add:

allow_url_fopen = ON

on php.ini (create new if not exists) solves the problem.

http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/

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