1

Does someone know how it is possible to upload multiple files with the dropbox client module for drupal 7?

It would be nice if it could be integrated with plupload.

Also i would like to know how i can predefine the filetypes users can upload?

I'm a n00b in php, can someone give me some tips or solutions?

Here is the part of the upload funktion in the dropbox client module.

function dropbox_client_upload_form( $form, &$form_state ) {

  $form[ 'upload' ] = array(
    '#title' => t('Upload file'),
    '#type' => 'file',
    '#size' => 20,
    );
  $form[ 'submit' ] = array(
    '#type' => 'submit',
    '#value' => t( 'Upload' ),
    );
  return $form;
}

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 ) ) );
  }
}

Thank you!

Best regards, meckl

1 Answer 1

0

Also i would like to know how i can predefine the filetypes users can upload?

Specify the file types restriction on the file field with 'file_validate_extensions' in the #upload_validators array in the file field. See the form api for reference. See the file_managed field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.