问题描述:

I am using the phpqrencode library to generate QR codes within a WordPress plugin. There are 2 possible codepaths. In one, the image is created and everything is happy town. In the other, the call to ImagePng within the library returns false.

I am writing lots of debug info to a file. The only difference I can find is that the image resource id being handed to ImagePng is consistently the same, but different between the 2 cases. So for example, when it works, it's always "Resource id #170" and when it doesn't, it's always "Resource id #283". I have added get_resource_type and they're both "gd" as they should be. Firstly, it seems odd that the IDs would always be the same - but I don't know much about garbage collection in PHP. Secondly, given that the params to ImagePng, filepath and the image resource, are both valid - I cannot figure out why it fails in the 2nd case.

Hoping for some suggestions on other things to look for?

网友答案:

Ok well, I was making a mountain out of a pimple. Turned out that the file was using a relative path and in the 2nd code path, the folder couldn't be written to. Oops. Changed to absolute path and now all is right in the world.

相关阅读:
Top