With the latest version of the module (7.x-2.x-dev 28feb) and the elFinder library (elFinder-lib-2.x-20120224_050001.tar.gz),
elfinder_ffsel module doesn't work when you select a file, I get a popup message: url=/sites/default/files/imagea.jpg
and show the error:"The file used in the File field may not be referenced."

(This happens when the images have been uploaded using "drag & drop".)

Thanks.

Comments

ph0enix’s picture

Status: Active » Needs review

Try to check April 17+ build.

nicodh’s picture

Status: Needs review » Active

For me, using elfinder_ffsel module, when I upload 2 files within elfinder popup, then I select one of them, and this throws 4 errors :

    Notice : A session had already been started - ignoring session_start() dans elFinder->__construct() (ligne 169 dans sites\all\libraries\elfinder\php\elFinder.class.php).
    Warning : filesize() [function.filesize]: stat failed for public://Hydrangeas.jpg dans elfinder_get_drupal_file_obj() (ligne 1157 dans sites\all\modules\elfinder\elfinder.module).
    Warning : filesize() [function.filesize]: stat failed for public://Koala.jpg dans elfinder_get_drupal_file_obj() (ligne 1157 dans sites\all\modules\elfinder\elfinder.module).
    Le fichier utilisé dans le champ Photos ne peut pas être référencé.

So I can't select a file uploaded with elfinder, and when I select a file with elfinder, the "add more" button disappears.

I use elfinder 7.x-2.x-dev (2012-04-19) with elfinder-lib-2.x-20120418_230001.tar.gz.

bancarddata’s picture

I am having the exact same problem. I was able to reference a file that had already been uploaded outside of elFinder, but one that was uploaded via elFinder 2.0 spat out the filesize() errors as well as a "The file used in the Image field may not be referenced". A quick search of the web indicated possibly a need for a "file_usage_add" call? Not sure.

bancarddata’s picture

I have updated to the latest dev and the issue persists. If I first upload the file using the regular file field upload widget, it works fine. I can even select a file with elfinder that I already uploaded with the regular field field widget, and that works fine too. I checked all of my directory and file permissions and all is ok.

I ended up making a change to elfinder.module at line 1172 and it seemed to get rid of the "file used in the Image field may not be referenced" error, however the filesize warning still displays (although the file size seems to be added to the database just fine). Here is what I modified:

I change line 1172 from:
$file->status = FILE_STATUS_PERMANENT;
to:
$file->status = 0;

Is this ok? Still not sure what I can do to get rid of the filesize warning. Also, there is another issue with the elfinder window not closing and therefore a new file widget does not appear so I have to save the node before I can add another file (this is an unlimited field). But, that is for another issue...

chris-ju’s picture

Priority: Normal » Critical

I agree with @bancarddata and I confirm that line 1180 has no reason to be !
If you comment the line 1180, you will not have the error "The file used in the File field may not be referenced." anymore.

The file cannot have permanent status if you don't have made any reference to it before.

Please apply this fix to this great module ! Thanks.

ph0enix’s picture

http://api.drupal.org/api/drupal/includes!file.inc/group/file/7

status: A bitmapped field indicating the status of the file. The first 8 bits are reserved for Drupal core. The least significant bit indicates temporary (0) or permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.

If file is temporary it will removed by system automatically when it will expired.

chris-ju’s picture

@ph0enix
Thanks for your response. Ok, I understand.
So I suggest to modify the elfinder.drupalfs.driver.inc file :

After line 250 :
@file_save($this->_drupalfileobject($path));

Add the following code :

// Record that the module elfinder is using the file.
@file_usage_add($this->_drupalfileobject($path), 'elfinder', 'elfinderFileFetcher', 0); // 0 : means that there is no reference at the moment.

This line add a "default" reference in the file_usage table.

What do you think ?

ph0enix’s picture

Let's try to test it. Use Jun 26+ build

ph0enix’s picture

Status: Active » Needs review
ph0enix’s picture

Issue summary: View changes

This happens when the images have been uploaded using "drag & drop".

bwaindwain’s picture

Issue summary: View changes

To all you googlers looking for answers, I had a similar problem. See https://www.drupal.org/node/2879571

bwaindwain’s picture

Status: Needs review » Closed (outdated)