1

I recently moved a Drupal 7 website from my development server to my pre-production server, and the rendering of the images from both the Body field and various images fields stopped working.

I now see "Image not found" and the URL of the image (which is working when I click on it by the way) on the generated PDFs.

The URLs from the Body field look like this "/mywebsite/sites/default/files/myimage.jpg" and the URLs of the "Image" fields are complete URLs with "http://mydomainname.com/mywebsite/……".

www-data has access to the images files and can also write in /tmp. And it does, actually, every time I generate a PDF with images. But the files are empty:

$> find /tmp -name "*dompdf*" -ctime -1 | xargs ls -lArth
-rw------- 1 www-data www-data 0 janv.  4 15:30 /tmp/ca_dompdf_img_0DlQ4V
-rw------- 1 www-data www-data 0 janv.  4 16:01 /tmp/ca_dompdf_img_Tyvv8w
-rw------- 1 www-data www-data 0 janv.  4 16:27 /tmp/ca_dompdf_img_pa4m4V
-rw------- 1 www-data www-data 0 janv.  4 16:27 /tmp/ca_dompdf_img_5RzNHk
-rw------- 1 www-data www-data 0 janv.  4 16:28 /tmp/ca_dompdf_img_T21gUJ
-rw------- 1 www-data www-data 0 janv.  4 16:29 /tmp/ca_dompdf_img_OmWxt2
-rw------- 1 www-data www-data 0 janv.  4 16:33 /tmp/ca_dompdf_img_SmA57m

I tried checking "Access images via local file access" in the "print" configuration page, but with no luck.

This may be an issue related to the server configuration, since it was working before on the development server, but I'm running out of ideas…

0
0

It's because your permission is -rw------- which only has read and write, there is no execute.

Use chmod -R 0775 sites/default/files

4
  • Hmmm, not right I'm afraid - for a start you shouldn't change files to 755, just directories (there are exceptions but you'd know about them, and this isn't one of them) - files should be 644. Secondly the OP has a problem with the /tmp folder (not sites/default/files), which does have the execute bit as the directory contents can be listed. Lastly, the fact that the files exist at all means it's not likely to be a permission issue, at least not with that folder. To test: sudo -u www-data touch /tmp/blah. If the file exists, the user can write.
    – Clive
    Jan 5 '16 at 12:38
  • @Bertrand31 You should find more information in your server's error logs
    – Clive
    Jan 5 '16 at 12:39
  • Yeah you're right about the 755, especially since this directory contains user-uploaded content. I already tried to su into www-data, and I can write files in /tmp/. I'll see if the logs tell me more.
    – Bertrand
    Jan 5 '16 at 13:00
  • Apache's access log showed me the HTTP request originating from my server and trying to retrieve the images resulted in 401 errors. This was actually all because of the htaccess authentication I had put up. Thanks @Clive!
    – Bertrand
    Jan 5 '16 at 13:12
0

Apache's access log showed me the HTTP request originating from my server and trying to retrieve the images resulted in 401 errors. This was because of the htaccess authentication I had put up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.