Image upload issue to standard drupal use profile

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
spessex's picture

Hi.

Pulling my hair with an image upload problem to a users profile. Been stuck for about 3 days on this now. Everytime I upload an image to the users profile (even on a brand new install with no additional modules and 775 set on default/files) when I upload it's says it carried out the action but there is no image. When I check in the firebug it is stating the image is linking to [http://www.domainname.com/sites/default/files/styles/thumbnail/public/pictures/picture-1-1382604947.jpg?itok=_UebH3-I] but there are no images in this section of the server. On investigating further I actually found the image sitting in [http://www.domainname.com/sites/default/files/pictures/picture-1-1382604947.jpg]. Can anyone explain why this is happening and how I might sort this?

Thank you

Stephen

AttachmentSize
Image not there?22.19 KB

Comments

Please also note that I never

spessex's picture

Please also note that I never have any problems with my local dev environment and all images upload with out issue. When checking for local dev they load to [http://localhost/linode/domainname/sites/default/files/styles/thumbnail/public/pictures/picture-1-1382607774.png?itok=Hq6tBYgW] where image can actually be found at [http://localhost/linode/domainname/sites/default/files/styles/thumbnail/public/pictures/picture-1-1382607774.png] but without the appending itok=Hq6tBYgW

What is the default settings

bapi_22's picture

What is the default settings for user profile picture?

Hi Thanks for your help with

spessex's picture

Hi

Thanks for your help with this but having gone on Drupal IRC chat for a long period of time, someone has managed to hold my hand and fix the issue.

It now appears that the reason why I couldn't upload images was due to permissions being incorrectly configured. " your nginx server is running through an user that has no write rights on your files because they are owned by another user. So unfortunately it was cockup made by those that configured the server.

To fix - following a long protracted checking procedure - they told me to:

  1. cd /var/www/domain.com/public_html/sites/default/ && sudo chgrp -R www-data files
  2. sudo service nginx reload
  3. cd /var/www/domain.com/public_html/ then drush image-flush

and immediately the images appeared and can now be uploaded.

Good thing to know. Hi

bapi_22's picture

Good thing to know.

Hi spessex,

Are you a freelancer or a professional developer?

Update for anyone that might

spessex's picture

Update for anyone that might experience this issue in the future.

The fix described above only worked on a fresh install, and unfortunately I'm still in the exact same position with the site in question (I'd used a fresh install as an experiment in this instance before I tested on the problem site).

So in general, I have a site that works perfectly on the local dev version (using MAMP) but is unable to display images or files on the remote server. I've had around 4 Drupal/Unix experts going through command line with me on terminal and checking/assigning various file permissions (which are all correct) but still we have the same issue, all permission looks correct but the image/file upload issue is still present.

Please also note I've tried

spessex's picture

Please also note I've tried this across two different servers now and the same problem is there.

What on earth could be so different from the local dev version and the remote version (please note both versions are the same files etc)?

It's probably still permissions

Andy_Read's picture

Hi Stephen. Sorry to hear you've had this frustration for days. It's almost certainly still a permission problem. The fix above is only changing the group of the files (chgrp). I would want to make sure I changed the owner as well with:
sudo chown -R www-data:www-data files
This assumes you've already identified that the web server is running as www-data user and group (check the ownership of a file it has managed to create, e.g. settings.php)

Another thing to watch out for is if you also FTP some files and content into the sites/default/files area, you may end up changing ownership of files to the user you use for FTP. This may well be the case if you copy everything onto your local dev environment and then copy it back to the server. Similarly if you create any files or folder with an SSH login.

It's probably still permissions

Andy_Read's picture

-- duplicate message due to g.d.o problems --

Stephen, Did you have a look

rajarju's picture

Stephen,
Did you have a look at the file settings page ?
Just to see if your tmp folder is good.
You confirm this by going to the media files settings page and submitting the form, with the current values you have.

rajarju

Hi guys. Thanks a lot for the

spessex's picture

Hi guys. Thanks a lot for the feedback. Apologies for the delay in responding only I've been away (and still am for a few more days and have only just seen the posts).

Andy, I had tried you suggestion but still the problem remained and Rajarju, the file settings all look good. HOWEVER, having researched a little further I played with the idea of disabling/turning off 'Clean URLS' in Drupal 7 and all of sudden the past images appeared and also any new images on upload. Turning 'Clean URLs' back on then took it back the original problem (of not being able to see/upload images etc). Now my only problem is why would two sites work with Clean URLS turned on and the other two not (and having to turn them off to work), considering they are on the same server (and again, all work with Clean URLS on with local MAMP)?????

Any further feedback would be greatly appreciated as I just do not understand why this should be so?

NginX config

Andy_Read's picture

Hi Stephen, apologies if the permissions angle has wasted your time. I've just re-read some of above and linked with the clean URL observation would say the problem may be in your NginX config (this was only alluded to as an aside above, but I think you're saying that a difference between your working local and non-working production is Apache v NginX).

I'm not very familiar with NginX config, but it's doing the equivalent of the Apache .htaccess file, which is what defines the rewrite rules for clean URLs and also defines access permissions and handlers for file types (e.g. images).

I suggest you google and look at a few threads on NginX Drupal config, e.g. http://wiki.nginx.org/Drupal and https://drupal.org/node/976392.

Finally, sorted the issue it

spessex's picture

Finally, sorted the issue it was related to a drupal bug:

https://drupal.org/node/944080