0

I am allowing a user to upload images via FTP into my private:// location as configured under File system. This location is owned by ftpuser:apache and has write permissions for both user and group.

Then my Content Type has a field called "picture file" which is the base filename of the image, e.g. IMG_9001.jpg

Note: I am using FTP instead of an Image/Media upload because the user will be uploading hundreds of images.

In my template, I do this:

$picture_file = $node->field_picture_file['und'][0]['value'];
$picture_file = 'private://' . $picture_file;
$picture_url = image_style_url('large', $picture_file);

This returns a correct URL with the itok parameter appended:

http://example.com/system/files/styles/large/private/IMG_9001.jpg?itok=xxxxxxxx

However, the image does not display. Going to the URL in another window gives an Access denied error. Even with

$conf['image_allow_insecure_derivatives'] = TRUE;

in my settings file, it still gives Access denied!

If I copy the file to the public:// location and changing the path it works. It's only the private:// location that doesn't work. Why wouldn't it work even chmodded to 777?

  • Do you have any other modules influencing file access, e.g a hook_file_download implementation? – David Thomas Sep 16 '13 at 22:51
  • @DavidThomas nothing custom. I looked through the list of contributed modules and nothing stuck out. Disabled Media and File Entity just in case but still Access denied – user11312 Sep 16 '13 at 22:55
  • Anything unusual in .htaccess, and you're using clean urls? – David Thomas Sep 16 '13 at 23:00
  • @DavidThomas yes I am using clean URLs, and no htaccess has not been modified – user11312 Sep 16 '13 at 23:01
  • @DavidThomas I gave up and am using timthumb to resize the images. Thanks for the help – user11312 Sep 16 '13 at 23:27

Your Answer

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