I've searched everywhere but I'm stuck on this problem.

I'm running Drupal 6.19 on a multisite configuration.

Let's say on my localhost, If I create an image node using image.module, and of course, I upload the file and it gets placed in sites/DOMAINNAME/files/images.

The image node works fine in localhost. But after I upload the actual image files to my server (/sites/DOMAINNAME/files/images), and upload the new database from localhost to my server, the image node still exists, but no image displays.

The file is there on the server, and I checked the database and the path is still there, but yet no image displays!
I can't figure out why this is happening.

I've tried changing permissions- no luck (even when everything is set to 777). I've also tried making sure the paths and filenames on my localhost and the server are absolutely correct. No luck either.

The same thing happpens if I create a new image node on my server and then transfer it to my localhost (along with the file, of course).

Anyone have any idea why this is happening?

Comments

pbarnett’s picture

Look at the HTML source code for the page and see what you're getting as the path to the image... that should give you a clue.

Matt G’s picture

Thanks for your suggestion. The problem was that no image was even displaying, not even an "image not found" error. Viewing the HTML source showed no img tag where the image.module image should be, and there was no way to "view image in a new tab" using Firefox or Chrome, etc., because there simply was nothing there.

Matt G’s picture

OK, I'm onto something.

I've found a way to get the image path to actually show up in the HTML source, even if no image appears (at least now I can see the "image not found" web browser icon).

The issue was this. On my localhost configuration, the site directory was sites/DOMAIN.COM
But on the server the domain's folder was sites/WWW.DOMAIN.COM

Aftering adding symbolic links the image source code now shows up, as described above:
ln -s /var/www/drupal/sites/DOMAIN.COM /var/www/drupal/sites/WWW.DOMAIN.COM
I've added these symbolic links to both my server and my localhost.

To avoid any potential problems from different paths, I changed my localhost apache virtual host configuration so that the going to http://DOMAIN.com on my local computer will load the localhost site.

But now, the link path of the image is weird. I copied my server SQL database to my localhost, and here's what the output image path looks like

http://DOMAIN.com/sites/DOMAIN.com/files/sites/www.DOMAIN.com/files/images/[image-name].jpg

No file is found there, or should be found there!
The path output should be:
http://DOMAIN.com/sites/www.DOMAIN.com/files/images/[image-name].jpg
or
http://DOMAIN.com/sites/DOMAIN.com/files/images/[image-name].jpg

So it looks like for some reason, I'm getting an extra sites/DOMAIN.com/files in my path output.

Any ideas on why this is? It seems as though PHP is outputting the sites/DOMAIN.com/files/ path twice. Once for www.DOMAIN.com, and another time for DOMAIN.com (without the www prefix).

Matt G’s picture

Looks like duplication of the sites/FOLDER-NAME/files path has occured before.

Related threads:

#1: File URL Being changed to /sites/default/files/sites/default/files
http://drupal.org/node/449892

#2: Media path being set to sites/default/files/sites/default/files
http://drupal.org/node/401140

#3: Duplicate folder path in URL
http://drupal.org/node/874356

#4: problem with clean url - duplicate path and other strange issues
http://drupal.org/node/133809
(This one is older)

Based on #2, it looks like this has something to do with the function file_create_path($dest)

Matt G’s picture

Other threads that discuss this issue:

#5: No images showing
http://drupal.org/node/750816#comment-2761700

#6: Imagefield path issues
http://drupal.org/node/752726

#7: File paths are incorrect, file directory path is repeated twice
http://drupal.org/node/587564

Matt G’s picture

Here is a workaround. It doesn't solve the underlyign problem, that is, Drupal repeating file path names (such as sites/default/files/sites/default/files), but it at least allows images to be displayed.

Create a symbolic link from your drupal/sites folder to your specific drupal/sites/DOMAIN.com/files folder:

ln -s /var/www/drupal/sites /var/www/drupal/sites/DOMAIN.com/files/sites

This way, when Drupal looks for a file in sites/DOMAIN.com/files, it will find a folder called "sites" that links back around.

So if your file is actually in sites/DOMAIN.com/files/[file-path] but Drupal produces a duplicate file path repeat that says sites/DOMAIN.com/files/sites/DOMAIN.com/files/[file-path], Drupal will still be able to find the file.

This should also work for the duplicate/repeat file path issue of sites/default/files/sites/default/files/][file-path]

djdevin’s picture

Possible explanation:

I found that when the Drupal filesystem path changed, but the entries in the drupal_files table were still pointed to the old path, Drupal treated those paths as relative - so it suffixed them after the filesystem path set in admin.

Solution was to either do a MySQL replace() on the drupal_files table, or, create a symlink from oldsite.com -> newsite.com in your sites/ directory. This solves the root issue of the paths being duplicated in the generated HTML.