Thanks for your answer and the example, but unfortunately it's not what I mean.
I'll just try to explain it again.
So up to now I have created a book automatically via code, in this book I create dynamically chapters in which pictures are
then uploaded. So far these images are uploaded as draft files with the "repository/repository_ajax.php?action=upload
So now comes my problem, I have to somehow manage to save these images as pluginfiles and not as draftfiles. These pictures should have the "component" "mod_book" and the "filearea" "chapter" in the "mdl_files" table. So far they have the "component"
"user and the "filearea" "draft ".
Thats an example of the draftfile (What I have now).
Thats an example how it should look like (What I want it to be ↑).
I would appriciate any help again (& Glady with an example again).