This issue seems to be intermitent and I cant put my finger on the cause.
Instead of files having a path such as
http://mysite.com/sites/mysite.com/files/myFile.pdf
I get a path like this
http://mysite.com/sites/mysite.com/files/sites/mysite.com/files/myFile.pdf

As you can see the files directory shows up twice in the file path. This has been causing any images, files, videos and other filefield related content not to display.

Any ideas?

Comments

epg’s picture

I have a very similar problem:

So I'm running a local test website in my windows xp machine using xampp. I have a content type that uses an image field and I uploaded my image. I see the image appear in my local sites/mywebsite/files directory when I upload it. So far so good.

In my live server, my website is installed in the default directory. When I export the database from my local machine and import into my live server, my content types show an "image not found" on the image. I looked at where it is looking for the image and it turns out that it is looking for it in the default/files/sites/mywebsite/files directory.

Should't it be looking in the default/files directory? Obviously, it somehow now thinks that default/files is some sort of directory root, but how do I configure/fix things in my local machine so that when I upload to live it doesn't try to look for things in a directory that doesn't exist?

To clarify, on the live site, the drupal is installed in public_html, my modules are in sites/all, and I installed drupal in the default directory (so it is in default where I have my settings.php file that points to my database). In this default directory I also have a files directory and here is where I think the image files should go (and that's where I copied them to), but it is looking for them in default/files/sites/mywebsite/files, which doesn't exist, because I only have a default/files directory with nothing in it other than my images (I put them there via ftp).

Any ideas?

quicksketch’s picture

epg, I'm answering your question in #409884: a way to refresh filepaths stored in database?. keyo, if this looks like the same problem as epg is having, then we may have found the cause. I answer this question on a nearly weekly basis, so let's try to keep these requests consolidated.

keyo’s picture

I always solve the problem quicksketch mentioned with a SQL replace. This has worked fine for me a number of times. This problem seems to be more intermitent. After running cron and clearing caches the paths will be correct, then a few days later the problem will occur again.

Imagecache/imagefield seems to be fine after I flush the imagecache presets. I guess the only way to really fix this is a full debug to find out which function is concatenating the file directory a second time to the paths.
From what I can see in the files table, all the paths are usual. e.g. sites/mysite/files/myfile.png

I'm guessing something is adding the files directory to the start of every path.

Any ideas?

ManyNancy’s picture

Aside from going to Drupal 7, is this bug basically unfixable?

quicksketch’s picture

Category: bug » support
Status: Active » Closed (fixed)

Aside from going to Drupal 7, is this bug basically unfixable?

Yes, this is unfix-able because it's not actually a bug. It's just the way that Drupal core stores file paths.

Matt G’s picture

I wonder if this problem is not related to filefield.

I have experienced the same problem (duplicating the path to an image, such as sites/default/files/sites/default/files/[image-name].jpg) on a website that is not even running CCK (let alone FileField). For me, this resulted in image.module image nodes being empty (as the image file path was incorrect).

This issue has come up with other modules as well. I wrote a more detailed account of it here:

Image.module images nodes image display field empty after moving from server to localhost (or vice-versa)
http://drupal.org/node/989428

regal’s picture

Issue summary: View changes

I've experienced this problem, and the solution was right under my nose.
There really was a new series of files that lead to that module location.
For me it probably came about from copying the file from my dev to production modules folder in an odd way.
But I was able to delete that file, and then it worked.

jamiehollern’s picture

For anyone who stumbles across this issue, you can fix it with a bit of SQL.

UPDATE file_managed
SET uri = REPLACE(uri, 'public://sites/default/files/', 'public://')
WHERE uri LIKE '%public://sites/default/files/%'