Problems with uploading images

Axel_V - February 2, 2009 - 20:02
Project:YUI Rich Text Editor
Version:5.x-2.6-96
Component:Miscellaneous
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I've just installed the YUI editor with Drupal 5.15 and I'm not running the library locally. I have uploaded an image with a post and it seemed to work all fine. However, when I try to upload different images with other posts it always comes up with the image that I've uploaded first. I then went onto the server and found a file called images. I was surprised that YUI seems not to store the image in its original form (jpg, etc...) but somehow embeds it into this image file with no file extension. I deleted this images file, tried to upload a new image, but again it comes up with this first image that I uploaded with the YUI editor. What is going wrong? I enabled the coder button in order to see where its pointing at but the coder button will not show (and no, I haven't got the plaintext button enabled at the same time).

#1

fyamashi - May 29, 2009 - 11:09

This problem can be solved by editing line 221 in yui_editor.module as follows:

//$path .= 'images';
$path .= $files[upload];

#2

ablondeau - October 5, 2009 - 21:37

I ran into this too on 5.x and modified the yui_editor_image_upload() function by replacing

$path .= 'images';

with

//remove the old "images" file (not directory) that may have been created before
if(filetype($path . "images") == "file"){
unlink($path . "images");
}

//create a user images directory if it does not exist yet
global $user;
$path .= 'images';
if(!file_exists($path)){
mkdir($path);
}
$path .= "/".$user->uid;
if(!file_exists($path)){
mkdir($path);
}

This not only fixes the issue with every image getting saved to a FILE called /files/images, but also makes it so that all images go to a specific folder for each user in order to reduce clutter.

 
 

Drupal is a registered trademark of Dries Buytaert.