cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Chooser - Set dropbox file as input type file value

Chooser - Set dropbox file as input type file value

gdiazderada
Explorer | Level 4
Go to solution

Hi there,

 

I'm using the chooser to allow the user to select a file which then should be set as the value of an input type=file of a form. Right now I'm trying to do this within the chooser success callback but doesn't work:

 

function DropboxChooser(selector)
{
    options = {

        // Required. Called when a user selects an item in the Chooser.
        success: function (files) {
// Also tried with the files property of the input document.querySelector(selector).value = files[0]; }, // Optional. Called when the user closes the dialog without selecting a file // and does not include any parameters. cancel: function () { }, // Optional. "preview" (default) is a preview link to the document for sharing, // "direct" is an expiring link to download the contents of the file. For more // information about link types, see Link types below. linkType: "direct", // or "direct" // Optional. A value of false (default) limits selection to a single file, while // true enables multiple file selection. multiselect: false, // or true // Optional. This is a list of file extensions. If specified, the user will // only be able to select files with these extensions. You may also specify // file types, such as "video" or "images" in the list. For more information, // see File types below. By default, all extensions are allowed. extensions: ['.pdf', '.doc', '.docx'], }; Dropbox.choose(options); }

What I'm missing here?

Thanks

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Thanks for following up with the additional information. It sounds like the Dropbox portion of this is working properly then, so I'm afraid I can't be of much help.

From your description, you're having trouble with the rest of the HTML/JavaScript work to be done with your app. That's outside the scope of Dropbox API support unfortunately.

For reference though, the Dropbox Chooser returns link(s) for the selected file(s) back to your app, not File objects or file data. (That way, all of the file data doesn't need to be sent through the user's browser.) What you do with those is up to you, but you generally would just send the link(s) up to your server, i.e., as text, not files.

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution
Can you elaborate on what exactly isn't working for you? For example, is the success callback getting called? What error do you get?

It looks like you're to set the value of some element to files[0], but each element in that array is a JSON object as documented here:

https://www.dropbox.com/developers/chooser#response

gdiazderada
Explorer | Level 4
Go to solution

The callback is being fired properly, the problem is it seems I cannot set the files property of an input of type file since it's readonly.

I got a form with an input file so the user can upload files from the computer. Also wanted to give the user the ability to upload files from the Dropbox picker, but I'm not sure how to handle that in terms of form submission and handling.

 

Thanks

Greg-DB
Dropbox Staff
Go to solution

Thanks for following up with the additional information. It sounds like the Dropbox portion of this is working properly then, so I'm afraid I can't be of much help.

From your description, you're having trouble with the rest of the HTML/JavaScript work to be done with your app. That's outside the scope of Dropbox API support unfortunately.

For reference though, the Dropbox Chooser returns link(s) for the selected file(s) back to your app, not File objects or file data. (That way, all of the file data doesn't need to be sent through the user's browser.) What you do with those is up to you, but you generally would just send the link(s) up to your server, i.e., as text, not files.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    gdiazderada Explorer | Level 4
What do Dropbox user levels mean?