Uploadcare Storing Group / Files

579 Views Asked by At

I am using the multifile picker instance of Uploadcare, but have turned off "autostore". How can I store files after user clicks a submit button?

I went through the REST API, but am really new to this, so its not really clear what I need to do. An example code would be quite helpful.

Thanks.

UPDATE:

Implemented the example, but am getting an internal server error. On my account I can see the images on the CDN, but none was stored. Here's my php code:

<?php

require_once 'Uploadcare/Api.php';
use \Uploadcare;

$public_key = 'xxxxxxxxxxx';
$secret_key = 'xxxxxxxxxxx';

$groupUUID = mysqli_real_escape_string($con, $_POST['groupUUID']);

$api = new Uploadcare\Api($public_key, $secret_key);
$group = $api->getGroup($groupUUID);
$group->store();

?>

Is there something am doing wrong?

1

There are 1 best solutions below

0
On

You have to issue a REST API request on your backend:

PUT /groups/:group_id/storage/

:group_id is submitted with a form by default.

For example, if you're using Uploadcare PHP package:

$group_id = $_POST['files']; // name of input field that is used by Uploadcare
$api = new Uploadcare\Api($public_key, $secret_key);
$group = $api->getGroup($group_id);
$group->store();