Make WordPress Core

Opened 18 years ago

Closed 17 years ago

#4427 closed defect (bug) (fixed)

When uploading files, can't use directory for file uploads one or more levels up from WP dir

Reported by: lelion's profile lelion Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.2
Component: Administration Keywords:
Focuses: Cc:

Description

Hello,

First time trying to report bugs :)

Here's a bug which appeared in WordPress since version 2.1.x upwards.

I am using currently 2.2, and it is still there.

It concerns blog setups, which use a dir for uploading files, which are higher in the file system on the server than the blog itself.

Here's a quick example:

I am using two blogs on my domain. One is in www.mydomain.com/bg/ and the other in www.mydomain.com/en/. (I blog in two languages, so I decided to create two blogs, instead of using a plugin.)

Being so, for me is much easier to make a directory for file uploads, which will be in the root of my domain, and will be used for both blogs. In this case, I use www.mydomain.com/wp-uploads/. There are uploded files via the WP integrated file uploader.

To specify this dir, when I first installed WP 2.05, I used the following format in OPTIONS -> MISC -> Store uploads in this folder: "../wp-uploads"

'../' usually means 'go higher one dir and count from there' and it worked :)

This worked fine, and when I uploaded files, WP made links like that:
http://www.optimiced.com/bg/wp-uploads/2007/03/image-file.jpg

After I made an upgrade to 2.1.x, and when I uploaded files, links became:
http://www.optimiced.com/bg/../wp-uploads/2007/03/image-file.jpg

Interesting, but this worked anyway, but still it's a bug. In the source files (I upload mostly images) become:
http://www.optimiced.com/bg/../wp-uploads/2007/03/image-file.jpg

...with '../' instead of '/bg/wp-uploads...' etc.

OK, I tried to re-define upload dir.

I tried to specify absolute path, instead of relative, like:

/home/myusername/mydomain.com/wp-uploads/

It didn't work, WP added "http://www.mydomain.com" in front and everything screwed up.

I tried "http://www.mydomain.com/wp-uploads/", it didn't work, either.

I tried to specify absolute path like '/wp-uploads/', it didn't work...

I tried everything, but nope.

After upgrade to 2.2, it is the same.

WP adds "http://www..." or directly uses "../" so in both cases I have wrong URLs to images and thumbnails :(

What can be done?...

Can WP again become flexible when specifying directories for upload which are higher, than where WP is installed?...

I am not sure what and where in the code of WP was changed but I know that in 2.05 when I used '../' in OPTIONS -> MISC -> UPLOADS DIR, it was resolved in the URLs correctly, and since 2.1.x, it is 'printed' directly (as is) in the links, so things to do not work anymore :(

I do not know enough PHP to propose a fix, but I am sure that if we can compare 2.05 and 2.2, a difference will be seen :)

I know other people who use an upload other than the default (and higher than WP is installed) and if bug fix is proposed and implemented, would be great:)

Thank you! :-)

I'll provide more details, if you need!

Change History (4)

#1 @rob1n
18 years ago

  • Milestone set to 2.4 (future)

#2 @lelion
18 years ago

  • Milestone 2.4 (future) deleted

I will try to compare 2.05 and 2.2 and if I can find a bit of code which might fix this bug, I will report here:)

Here other people mentioned same problem:
http://wordpress.org/support/topic/76242
...so it didn't happen only in my case:)

Thanks in advance! :-)

#3 @rob1n
18 years ago

  • Milestone set to 2.4 (future)

#4 @nbachiyski
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

You can now specify both relative path and a URL of the uplaod directory in Settings -> Misc.

For patch/discussion see #5953.

Note: See TracTickets for help on using tickets.