ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Image uploading failing on Windows due to DIRECTORY_SEPARATOR confusion

July 02, 2012 5:05pm

Subscribe [1]
  • #1 / Jul 02, 2012 5:05pm

    FTIC

    14 posts

    This question may be related to a resolved thread.

    EE 2.5.2
    Windows 7 64-bit

    Hello!

    I have a File field which I’m using to upload an image on Windows. I’m receiving the error “Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable”.

    I’ve confirmed that my paths exist and are writable.

    Inside of Image_lib.php, the destination path for image thumbnails gets messed up. As a result, EE is unable to write the image file.

    The problem occurs on line 212 in Image_lib.php.

    if (strpos($this->new_image, DIRECTORY_SEPARATOR) === FALSE)

    It bases a conditional statement on DIRECTORY_SEPARATOR (aka “\” in Windows). The problem is that $this->new_image has unix-style separators (i.e. “/”). Therefore the conditional on line 212 evaluates incorrectly.

    I printed out the paths during the process and you can see where it goes awry:

    $this->new_image: d:/ee/images/uploads/_thumbs/temp_file_issue_71.jpg

    Line 212 will not find DIRECTORY_SEPARATOR in this image path and it will assign this full path to $this->dest_image. dest_image is expected to be only the image name. Later, this full path gets combined with $this->dest_folder which results in a “doubled” image path (see $this->full_dst_path). At that point, EE is unable to save the image.

    $this->dest_image: d:/ee/images/uploads/_thumbs/temp_file_issue_71.jpg
    $this->dest_folder: d:/ee/images/uploads/
    $this->full_src_path : d:/ee/images/uploads/temp_file_issue_71.jpg
    $this->full_dst_path : d:/ee/images/uploads/d:/ee/images/uploads/_thumbs/temp_file_issue_71.jpg

    So, it’s not Image_lib’s fault but for now I’ve stuck this hack on line 212:

    if (DIRECTORY_SEPARATOR=="\\") $this->new_image = str_replace('/',DIRECTORY_SEPARATOR, $this->new_image);

     
    Could something in my config be causing this?

  • #2 / Jul 03, 2012 3:53pm

    Dan Decker

    7338 posts

    Hi FTIC,

    Thanks for posting your question and welcome to ExpressionEngine and the Forums!

    Could something in my config be causing this?

    Not likely in your ExpressionEngine config, but there may be something about your Windows set-up.

    How are you running ExpressionEngine on Windows? IIS, apache, PHP as CGI, WAMP, etc?

    Cheers,

  • #3 / Jul 05, 2012 12:51pm

    FTIC

    14 posts

    Hi Dan - I’m using WAMP with the default setup.

  • #4 / Jul 06, 2012 10:41am

    Shane Eckert

    7174 posts

    Hi FTIC,

    Are you the Administrator on this system? Is there a team or a hosting company that provides hosting? I am wondering if they could take a look and see if there is something within Windows that can be done. I know Linux really well, but I do not have any Windows experience to draw on.

    Please let me know.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases