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.

Discuss Dropbox Developer & API

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

Upload files to a specific folder using javascript

Upload files to a specific folder using javascript

h_vohra
Explorer | Level 4
Go to solution

I want to upload my files to a specific folder in dropbox, I am using the filesUpload function to upload files. I want that the folder gets created 1st and then the files are stored in that folder.  Below is my code.

 

opencart-setup.png

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

:slight_smile: If you aren't sure what my advice mean, better keep your way of coding for now.

Would be enough to concatenate file name to the folder path. Transform everything in your code which seems:

dbx.filesUpload({path: '/' + fileName, contents: file})

To something like:

 

dbx.filesUpload({path: '/' + folderName + '/' + fileName, contents: file})

Seems you just forgot it. :wink:

Hope this helps.

 

View solution in original post

5 Replies 5

Здравко
Legendary | Level 20
Go to solution

Hi @h_vohra,

I'm just curious, Is there any problem outside fact that you put your file on root level, not in just created folder? You don't report any actual issue!

One advice: when you refer to particular place (folder), it's better practice avoid path in text form, use id instead. Just advice, nothing more (id is more stable way).

h_vohra
Explorer | Level 4
Go to solution

Different users will upload files from the form, so I need it to go on different folders to distinguish properly.

 

Can you please help me how to get the ID, and add it in the path , I tried adding the folder name in path, but it gave error

Здравко
Legendary | Level 20
Go to solution

:slight_smile: If you aren't sure what my advice mean, better keep your way of coding for now.

Would be enough to concatenate file name to the folder path. Transform everything in your code which seems:

dbx.filesUpload({path: '/' + fileName, contents: file})

To something like:

 

dbx.filesUpload({path: '/' + folderName + '/' + fileName, contents: file})

Seems you just forgot it. :wink:

Hope this helps.

 

h_vohra
Explorer | Level 4
Go to solution

Thanks for the solution, I am new to working with Dropbox API

Peterdc
New member | Level 2
Go to solution
Yes
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Peterdc New member | Level 2
  • User avatar
    h_vohra Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?