Multiple document uploads in forum posts

Hello,
I would like to enable multiple document upload in forums.
I can see that the way SPIP handles document uploads in forums is that it stores the the document in the session, and when the forum post is inserted into the database, this document is associated with the forum post.
For multiple documents upload, I start with changing the form type to multipart:

        <form ...  enctype="multipart/form-data" ...>

But after, the modifications because of the document being stored in the session seem quite hard.
I can loop through the uploaded document. Is there a way to add the documents securely to the forum post created directly in the traiter function?

Thank you.

Not sure it’s what you’re looking for, but once the forum exists, you can :
#FORMULAIRE_JOINDRE_DOCUMENT{new,#ID_FORUM,forum}
cf https://www.spip.net/fr_article6360.html

Yes, that form works to add multiple documents, thank you JLuc.

Also in it’s source, one can find the relevant function that takes a PHP $FILES array and associated the uploaded files with an object.

File: plugins-dist/medias/action/ajouter_documents.php
Function: action_ajouter_documents_dist($id_document, $files, $objet, $id_objet, $mode)

Merci

1 « J'aime »