i installed the image_import.module with the brand-new drupal 4.6 but i always got the message "No files were found in the import directory." when trying to import images. i'm no php-expert but i figured out that it's something to do with the list of extensions in $mask passed to file_scan_directory(). i suppose this is caused because there's no variable "upload_extensions_2" which is called in _image_import_check_ext(). at least i couldn't find it in my database. i worked around this by setting $mask = '\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)$';
i don't think this is the right way to fix it, however it works for me...

Comments

rangermeier’s picture

Title: no extensions in $mask » no bug...

this "bug" was caused by a badly set up upload-module. sorry...

syscrusher’s picture

Assigned: Unassigned » syscrusher

No harm, no foul. Thanks for letting me know not to work on this. :-)

Scott

rangermeier’s picture

i've just got a mail that someone had a similar problem.
i solved this by setting up the permissions for upload.module at administer/access control.
also check at administer/settings/uploads if the permitted file extensions are set up correctly (at least "jpg jpeg gif png" or whatever images you want to import).

trevleyb’s picture

Category: bug » support

I can't seem to get the image_import module to work at all, and was wondering if someone could shed some light. I have installed it onto a 4.6 Drupal system with the latest image.module installed from Walkah. Upload.module is enabled and all permissions are setup and I have a files/image_import/ path setup which has 777 permissions.

When I click on preview or import nothing happens. No messages except it looks like it does a quick refresh of the page but there is nothing else noticable.

Any ideas of what I might have wrong?

trevleyb’s picture

Sorry, a followup to my previous post. I added a bunch of 'print' statements to track through the code and found that it references 'upload_extensions_2' to get a list of file extensions. However, in my variables table, there is no definition for 'upload_extensions_2' but there is one for 'upload_extensions_3' --- I changed it to 3 and it seems to work, although doing a preview does not show anything.

Thanks,
Trevor

syscrusher’s picture

Regarding the post from rupi (#3) -- good point about the need to have the right permitted extensions. I'll be sure to put that into the user documentation.

Scott

syscrusher’s picture

Title: no bug... » no upload files found in image_import.module
Category: support » bug
Priority: Normal » Critical

> Sorry, a followup to my previous post. I added a bunch of 'print' statements to
> track through the code and found that it references 'upload_extensions_2' to
> get a list of file extensions. However, in my variables table, there is no definition
> for 'upload_extensions_2' but there is one for 'upload_extensions_3' --- I changed
> it to 3 and it seems to work, although doing a preview does not show anything.

Wow...This was a sneaky bug! Good catch.

The reason I coded 2 into my code was because that's what I found in my {variable} table, and I assumed it had to do with the code revision of the upload module. Zap! I should have looked more carefully. That two is not a constant, but a variable, tied to an individual role ID number. Looks like I need smarter logic in that part of my module. I'll get this fixed and uploaded to CVS ASAP.

Thanks for a terrific bug report.

Scott

syscrusher’s picture

I think this is now fixed. Testers please grab the new version from:

http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/syscrusher/im...

I would appreciate any test reports from this version. Changes include some UI and
documentation improvements as well as the correction (I think) of this bug.

Scott

dvonbieker’s picture

Title: no upload files found in image_import.module » Latest release does not fix problem

I have tried 1.7 and nope - doesn't seem to fix the issue. It will not find images in the directory. Weird. I can navigate to them manually - I know they are there. I even changed my roles so I only have one - and yes I have upload permissions and yes I can upload image extenstions. I could tell it was something to do with extensions because in teh "help" that comes up the extensions are not listed, just something like "./"

A fix would be VERY appreciated - as I would love to start using this module. It seems almost essential to drupal in my mind.

syscrusher’s picture

Hi, Rupi

I think I might know what is going wrong, and if I'm right, it's a subtle config problem rather than a code bug. I'll explain what I think is happening; please check into it for me, and let me know what you find. If it's a code bug, of course, I'll fix it ASAP. If it's the config problem I think it is, then I may still change the code -- to specifically detect that problem and explain to the user how to fix it. :-) But first we need to know for sure.

If you go to path q=admin/settings/upload, you'll see (hopefully) that the extension list is now broken out by security role. What I think may be happening -- and indeed, what happened to me on my test system, resulting in much puzzlement -- is that the user who is trying to upload the photos is not configured with any extensions of an image type.

Please check for this situation. If you still can't resolve the problem, then please post the results of the following SQL queries, if you don't mind:

select * from role;
select * from variable where name like 'upload%';
select ur.*, u.name from users_roles ur left join users u on ur.uid=u.uid where name='UUUU';

(In the last one, replace UUUU with the actual username that is trying to upload the pictures.)

Another diagnostic: While logged in as the system user (uid==1), try going to q=node/add/image_import/help and check to see if any extensions are listed. If some are listed there, but none listed when you're logged in as the regular user, then this suggests that the problem is that the regular user is not a member of any role that is allowed to upload image files.

One final possibility, and this one I'll definitely add a specific test in the code to handle if it occurs. The regular user account may not have the "upload files" permission for upload.module. image_import uses upload.module's API library and permissions settings, so I need to be more explicit in the documentation -- and in the runtime sanity checks -- to indicate that the user needs that permission.

I'm sorry you're having trouble. I hope one of these possibilities turns out to be the cause; if not, I should be able to figure it out from the SQL queries listed above. Once we have this pinned down, I'll try to smarten-up the code to specifically test for the situation you've encountered and provide meaningful diagnostics to identify the problem for the user.

Kind regards,

Scott

syscrusher’s picture

Sorry -- my previous post was meant for dvonbieker, not rupi. Mea culpa.

Scott

syscrusher’s picture

Version: » master

The latest release (the one in contributions/modules/image_import under HEAD branch) corrects this problem. The site administrator is now able to import any valid extension (that is, any supported by the module itself). The code also now explicitly checks to see if the current user has "no" available/allowed extensions, and suggests the needed config changes in that situation.

Scott

Anonymous’s picture