You are here

function dropbox_client_upload_form_submit in Dropbox Client 7.4

Same name and namespace in other branches
  1. 7 dropbox_client.module \dropbox_client_upload_form_submit()
  2. 7.2 dropbox_client.module \dropbox_client_upload_form_submit()
  3. 7.3 dropbox_client.module \dropbox_client_upload_form_submit()

File

./dropbox_client.module, line 517

Code

function dropbox_client_upload_form_submit($form, &$form_state) {
  global $user;
  $dropbox = dropbox_client_get_client();

  //Process files
  $uploads_dir = dirname($_FILES['files']["tmp_name"]['upload']);
  $tmp_name = $_FILES['files']["tmp_name"]['upload'];
  $name = $_FILES['files']["name"]['upload'];
  $filename = "{$uploads_dir}/{$name}";
  move_uploaded_file($tmp_name, $filename);
  $dpath = isset($_GET['dpath']) ? $_GET['dpath'] : '/';
  $result = $dropbox
    ->add($dpath, $filename);
  if (property_exists($result, 'error')) {
    drupal_set_message($result->error);
  }
  else {
    drupal_goto($_GET['q'], array(
      'query' => array(
        'dpath' => $dpath,
      ),
    ));
  }
}