Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
would be a way to insert an upload file to the database?
this way these files would be available to all other modules/nodes to use them. Some times it would be better than removing them and they would stop appearing in the log.
thanks.
Comments
Comment #1
Stuart Greenfield CreditAttribution: Stuart Greenfield commentedCan you clarify what you mean here? The files table links files to nodes, so that the files on the system have a node that owns them. If the file appears in the report it means that the connection is broken. If you were to "re-attach" files then you would need to choose the node that you want to link to and you wouldn't really know where to put it!
The best option in this case might be to download the file using FTP, and then edit the relevant node and re-upload the file that way?
If I have missed something then if you can explain a little further how you might see this working then I can understand how this might work.
Hope that's ok!
Comment #2
enboig CreditAttribution: enboig commentedSorry, I didn't think carefully before writting. I will explain my situation:
I am using IMCE to attach images and files to nodes, but these files aren't really associated to the node, if I remove a node, the file isn't removed. So I was thinking about a way to insert these files to the nodes which are using them. This way it would be easy to remove files.
After reading more and thinking about it I think maybe it would be IMCE who should use uploaded files in the node...
The good things and bad of every alternative are:
* IMCE use attached files:
+ seems easy to code.
+ it could use "inline" or "Path Filter" so if you move your site to another location everything works ok.
- you are limited to upload files, you cannot use FTP to upload big files (now you can do it).
- you cannot share files across nodes
* Audit files attach used files to the nodes using it:
? I don't know if a file can be "belonged" by more than one node.
+ you could upload big files with ftp and they would be used by any node.
+ if a file is used twice or more, you could save space; and if you have to change the uploaded file, you just have to do it once.
- I think it would be hard to code.
mmmm..... these are my thoughts, any idea is wellcome.
Comment #3
acondiff CreditAttribution: acondiff commentedI am in the exact same boat as you are in. I am using IMCE, and I want to be able to write uploaded FTP files to the database. Sorry for opening an old thread however if anyone has any suggestions that would be great! Thanks.
Comment #4
acondiff CreditAttribution: 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 #5
acondiff CreditAttribution: 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 #6
nuthman CreditAttribution: nuthman commentedUsing Filefield 6.x-3.7
My version was slightly different. I found and commented out the code block under the filefield module in filefield_widget.inc and it looked like this:
if (field_file_references($file) == 0) {
form_error($element, t('Referencing to the file used in the %field field is not allowed.', array('%field' => $element['#title'])));
}
commenting that out worked for me! Thanks
Comment #7
giginos CreditAttribution: giginos commentedHi acondiff,
thanks for shareing your code.
I got the stuff working on Drupal 7 while changeing the module-file filefield_sources/sources/inc/imce.inc
Hope this helps someone:
Cheers,
Rafael Kutscha