Anyone has a working example using "file" in forms?

26 views
Skip to first unread message

Tomas Dalebjörk

unread,
May 22, 2023, 6:57:23 PM5/22/23
to Joomla! General Development
Hi,

I am trying to follow the "com_media" but it is not easy to follow.
I know, I can write it using a few lines of codes in the Controller; which I have done.
But I need to do it the "Joomla way".

Why?
Cause it is not possible to POST multiple rows using the webservices.
Eg

curl --location \
        --request POST 'https://localhost/api/index.php/v1/media/files' \
        --header 'Accept: application/vnd.api+json' \
        --header 'X-Joomla-Token: secretkey' \
        -d '{
                "posts" : [
                {
                        "name" : "test.csv",
                        "path" : "/images/a.png",
                        "content" : "file=@a.png"
                },
                {
                        "name" : "test.csv",
                        "path" : "/images/b.png",
                        "content" : "file=@b.png"
                }
                ]
        }'

So I was thinking, if it does not work to POST multiple lines, why not upload a file instead, using the above method, and loop that csv file to load the data.

But.. It isn't easy to know how to use the "file" in forms.
And there are no examples in Joomla either..

Anyone has a good working example?

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages