Drupal IMCE SWF Upload Patch

Submitted by james on

I had the chance to play around with the Drupal IMCE module in the last couple of weeks, and was impressed. It's a slick module that lets your users manage their own folder, upload files, etc. The user interface is pretty cool, and it's all handled through AJAX so you never navigate away from the page. You can set allowed file types, user memory quotas, etc.

By default you can only upload one file at a time. I needed to upload files in bulk, so I installed the IMCE SWFUpload module.

Apparently this module was developed for The Whitehouse. I wonder what they're using it for...

It worked for a while, but things ground to a halt when I received the error:

 

"Error uploading file nameoffirstfile.gif: Invalid user"

 

I tracked down the problem to the following few lins in swfupload/swfupload.module:

 

    $_COOKIE[session_name()] = $_REQUEST['sid'];
   
$sess_result = sess_read($_REQUEST['sid']);
    if (
$sess_result == '') {
      print
"{status : 0, message : 'Invalid user'};";
    }

?>

 

For whatever reason, the cookie could not be read inside the sess_read function. It was like the cookie was outside of the scope of that function.

To circumvent the problem I changed the following line:

 

    if ($sess_result == '') {
?>

 

To:

 

    if ($user->uid < 1) {
?>

 

That fixed the problem for me. As far as I know checking if the user id is greater than zero is sufficient to check if the user is an authenticated user, and not anonymous.

Here's a link to the issue, and patch file:

IMCE SWF Uploader Patch

Hopefully this helps someone!

I'm planning on making a video tutorial on installing the IMCE SWF Uploader, as it takes a few steps.

Also, I've written an IMCE module that gives users the capability of emailing links to their uploaded files. Stay tuned for the release, after I clean up the code!

Edit: 4 years later I've come to dust off this blog. Here's a link to the IMCE Mailer module for Drupal 6:

https://www.drupal.org/project/imce_mailer

Article Categories