You are here

function bynder_upload_process_files in Bynder 7

1 string reference to 'bynder_upload_process_files'
bynder_menu in ./bynder.module
Implements hook_menu().

File

includes/bynder_upload.inc, line 79

Code

function bynder_upload_process_files() {
  if (!empty($_FILES)) {
    if (isset($_POST['bynder_form_token'])) {
      $savedFiles = array();
      $folder = variable_get('file_default_scheme', 'public') . '://bynder_tmp/';
      file_prepare_directory($folder, FILE_CREATE_DIRECTORY);
      foreach ($_FILES['file']['name'] as $key => $file) {
        $source = $_FILES['file']['tmp_name'][$key];
        $destination = file_stream_wrapper_uri_normalize($folder . $_FILES['file']['name'][$key]);
        $uri = file_unmanaged_move($source, $destination, FILE_EXISTS_RENAME);
        $file = file_uri_to_object($uri);
        file_save($file);
        $savedFiles[] = $file;
      }
      $_SESSION[$_POST['bynder_form_token']] = $savedFiles;
      drupal_json_output(true);
    }
    else {
      drupal_json_output(false);
    }
  }
}