I read the other 2 threads relating to this issue and I think mine is a little different. I uploaded a file through the image field, It is saved in the author-named folder I have specified. I try to use the File browser option to select it for another node. I get the error. Is this the same issue? I should think it's in the DB if I uploaded it through the node in the first place, right?
A further frustration - I swear it worked once then stopped working. In fact, inspection of the code of the 2 nodes shows that they have the same filename, rather than file.jpg and file_0.jpg - so it must have worked.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | imce.inc_.patch | 1.11 KB | ufku |
| #4 | imce.inc_.urldecode.patch | 762 bytes | ufku |
Comments
Comment #1
Poieo commentedI'm having a similar issue, and I think it may be related. It seems you can only reference files that were added before your referencing field.
If you create a node, add a file via filefield, then save that node...you can then create another node containing a filefield sources field and reference that field.
However, if you create a node containing a fieldfield sources field first, then create a node with a field you wish to reference, you cannot edit the node containing the sources field and add the file you just created.
I'm not sure if this is clear, but I had the problem with the autocomplete field and the file browser.
Comment #2
dwong127 commentedI've had the same issue attempting to reference files with spaces in their name. The problem seems to be in the filefield_source_imce_value() function in imce.inc: it does a query based on the filepath, but the incoming filepath is URL-encoded (spaces are replaced by "%20", etc.) and this causes the $file_path variable to not match what's stored in the files.filepath database column. I think that a call to urldecode addresses the issue.
Updated function:
Comment #3
quicksketchOoo, nice find dwong127. A patch would make these changes easier to review, but this sounds promising.
Comment #4
ufku commentedHere is a patch that uses rawurldecode as IMCE uses rawurlencode for encoding file names.
Comment #5
brian_c commentedCan confirm that the current release's file browser only works on files with no spaces in the name.
We have applied ufku's fix (using rawurldecode() on $file_path) and can confirm that it works.
quicksketch, any chance of a reasonable assurance that the next release will have this issue addressed? Would just like to know if we need to worry about updating to a later version in the future. :)
Seemed appropriate to bump this one up to Critical, spaces are everywhere in this crazy post 8.3 world. ;)
Comment #6
Tails commentedI get the same error, even with the patch applied.
Is the module supposed to be able to select images that have not been used before?
What I am trying to do is to upload an image via FTP, and then to use it with FileField.
[edit] whoops, I accidently changed the issue settings... I thought it was post specific.
Comment #7
czperry commentedI applied the patch and was getting the same error too.
I tracked it down to the fact that IMCE absolute urls was turned on. The database query to look for the uploaded file needs to strip out the base path.
Comment #8
ufku commentedAdditionally disables absolute URLs.
Comment #9
jordanaThis indeed seems to works very well!
Thanks very much!
@ #6 Tails - check out this thread about using files you've uploaded through FTP:
http://drupal.org/node/438940
I've tried the patch and it works well enough for me.
Comment #10
jackalope commentedHad the same error due to spaces; the patch in #8 took care of the error. Thanks!
Comment #11
aaronbauman#8 is go!
Comment #12
heavy_engineer commentedHi
Tested on Pressflow 6.15.73 AOK as well (as to be be expected)
Great module. thanks.
Comment #13
quicksketchThanks ufku! Finally committed.
Comment #15
david3000 commentedHello guys, I have this same issue "The selected file could not be used because the file does not exist in the database" when I try tu set set an image from the browser. I tried all these patches but nothing, allways the same. All the permitions are set right on my server by the way. I never had this issue before in others modules or patches, just in this one. Also, when I use the IMCE module alone works ok, for example uploading by my account. I really need a little help about this. Thanks in advance.
Comment #16
acondiff commentedi need some help too. I am also experiencing this issue. I commented out the code that filters files visible to imce that are not in the database because I would like to use those files. The need to be added to the database on-the-fly or as they are selected for use in the node. Any help would be amazing.
Thanks.
Comment #17
acondiff commentedSo I found a solution. In imce.inc in the filefield_sources module, instead of this:
put this:
So this basically creates a database entry for new files that are not in the database. So now when I click insert it inserts the image, although, whenever I go to save my node I get this error: "Referencing to the file used in the field is not allowed."
Does anyone know what is wrong here?
Thanks.
Comment #18
acondiff commentedOk I found a solution for that as well so it does not throw the error. In the filefield module, I just commented out this block of code and it works like a charm.
Comment #19
pianomansam commentedThis solution seems to be working for me, but as it hacks filefield, it should only be a temporary solution. We need to find a better way to get this working again.
Comment #20
pianomansam commentedComment #21
cheyer commentedsubscribe
Comment #22
Luciuz commentedsubscribe
Comment #23
fugazi commentedsubscribe
Comment #24
vrajak@gmail.com commentedLooking for a fix, and this seems to be related: http://drupal.org/node/441280
Quicksketch strongly recommends against doing what is posted in comment #18. See http://drupal.org/node/441280#comment-2884196
Comment #25
soyyo commentedsubscribe
Comment #26
Crom commentedsubscribe
Comment #27
quicksketchPlease do not reopen this issue, the original problem has been solved.
For IMCE users who get this error when selecting a file, see #436182: IMCE lists unusable files (The selected file could not be used because the file does not exist in the database).
Comment #28
pianomansam commentedquicksketch, I do not think it is appropriate to label this issue as closed and fixed because the solution provided in #436182: IMCE lists unusable files (The selected file could not be used because the file does not exist in the database) has not been committed. Labeling as a duplicate probably makes better sense.