The dropbox plugin – working version

Good news comes better late than never, and with that in mind the plugin should now be uploaded to wordpress.com and be fully functional.

There have been several changes to how the plugin looks and work, which have taken me through several libraries, feature lists and bugs. It’s a bit of a patch job so I make no guarantees for stability, usability, security, or risks to global warming. The innards are a complete mess, but it appears to work. Since nobody came here for stories I’ll cut straight to the ‘how to’:

To access your dropbox you will need to set up a dropbox app in order to get a consumer key and a secret key.

1) Go to https://www.dropbox.com/developers/apps

2) Click “Create an App”

3) Add a name and description

4) Copy and paste the two codes in thee corresponding text boxes of the plugin options screen

To display the box use the shortcode with these parameters:

Name (default value) – description

home() – root folder, case sensitive, ex: /Photos

separator(~) – folder separator used in displayed box

hometext(home) – text for link to specified root

dirsfirst(true) – display directories before files

orderby(date) – parameter to order files and folders, possible values: date, size, type

orderdir(1) – 1 for asending -1 for descending

showdirs(true) – show directories in box

dateformat(l jS \of F Y h:i:s A) – format for date

allowdownload(true) – allow download of files, can be true/false

allownavigate(true) – alow folder navigation, can be true/false

columns(INDSD) – order of columns I:icon, N:name, D:date, S:size, a column may appear more than one time or not at all

asctxt(▲) – text used for link for ascending ordering

desctxt(▼) – text used for link for ascending ordering

ordering(true) – allow user to order the files/folders

allowupload(false) – allow user to upload files to current folder

In order to add icons place files in the ‘images’ folder(located in the plugin folder). File names must be ‘[extension of file].png’. For example ‘txt.png’ will be used as the icon for all *.txt files, ‘folder.png’ will be used for folders, and ‘default.png’ will be used for everything without a match.

As the plugin uses this wonderful library a special thanks goes out to its creator.

Note: the home parameter must be defined as

home=”/pathto/folder”

and NOT
home=”pathto/folder”
or
home=”/pathto/folder/”
or
home=”pathto/folder/”

CLICK FOR THE DEMO PAGE | CLICK TO DOWNLOAD THE LATEST VERSION

To do:

  • home parameter correction
  • pagination
  • upload forms
  • option to hide files
  • compatibility with folder restricted app
  • thumbnails
  • cache
FAQ/troubleshooting:
Q: It doesn’t download big files!
A: It probably doesn’t and you really shouldn’t try. It’s a great way to make your host angry. What happens is the plugin loads all the file contents internally then spits them back out. It doesn’t ‘stream’ files.
Q: I get corrupted files several KB in size, why?
A: Open them up in notepad and let me know what’s inside.

Q:Has this plugin made you famous? rich? the envy of all your friends? or just been really useful? Want to show your appreciation but don’t know how?

A:You can buy me a beverage of your choice:

VN:F [1.9.22_1171]
Rating: 8.0/10 (6 votes cast)
The dropbox plugin - working version, 8.0 out of 10 based on 6 ratings
  • NERD

    Big newbie here. I’ve setup my app so that my page has access to dropbox. How do i get something like what is shown in the demo to  appear on my page?

    • NERD

      Never mind i worked it out. The shortcode is [dropbox] for anyone looking.

      The problem i’m having now is that almost every time i click anything including folders i get a message saying “if you see this you were probably not playing nice, if you were, this error comes from the dropbox plugin”

      • NERD

        and while I’m here bugging you. is there any way to make image files open in browser rather than automaticall download?

  • Webhank

    my instance seems to “cache” the current files in dropbox for quite some time before “recognizing” that new files have been added -is there a way to either:
    1. force cache refresh
    2. lower the amount of time of this caching?

  • Webhank

    my instance seems to “cache” the current files in dropbox for quite some time before “recognizing” that new files have been added -is there a way to either:
    1. force cache refresh
    2. lower the amount of time of this caching?

    • Andrew

       There is no caching. Unless you have another plugin that handles global caching the issue is with your browser. In case it’s a plugin try to exlucde the dropbox pages from the cache. Let me know either way

  • Mathewarthur

    This plugin is awesome and works perfectly for me. I am using WP with a number of plugins to manage a client login area on my site – this plugin provides a perfect means of file-sharing for all my clients. Thanks!

  • Witek

    Didn’t work on one host. Works perfect on my other one (Hostgator). Guess it’s all down to which host you’re with.

    • Andrew

      If you could nail down the differences in server settings and post them maybe I can try to get it to work on more configurations.

  • pgprovenzano

    Congratulations for your plugin, it’s the first that works on my godaddy hosting! Two questions (newbie):

    when I connect to the page with the shortcode in all I can see is a explorer window showing me my dropbox folder and subfolders, and lets me navigate and even click on files and see them. But how can I add a upload button? and is it possible to have a visual progress bar for the upload?Also, second question, I’d like to allow each user to have access only to a specific folder, but if I use a dropbox application that has access only to a specific folder this plugin returns me an error, how can I fix this?
    Thanks a lot for your plugin
    Pier Giorgio (UK)

    • Andrew

      add 

      allowupload=”true”

      I’m not sure what you’re trying to do for the second part. There are multiple ways of getting that effect.

      • pgprovenzano

        Thank you so much! Awesome plugin

  • Flowbot Botflow

    nevermind – overlooked the FAQ :]

  • Reggiescottjr

    Everytime I try to connection the dropbox plugin with my dropbox account, I get an error. I dropped in the two “keys” given by the app I created on dropbox.com, then I click the “Click here after you saved everything..” link. Get to the authorization of dropbox, but when it comes back to my site I get a “The connection was reset” error. Any insight would help. I am hosted with GoDaddy.

    • Reggiescottjr

      Got the plugin working but when I try to upload a file I get this error:

      Warning: mkdir() [function.mkdir]: No such file or directory in
      D:hosting7362302htmldune-grasswp-contentpluginsdropbox-plugintdp_main.php
      on line 338

      Error: Can not create temporary directory!

      Any insight to how I can fix the issue?

  • http://www.facebook.com/rilana.martinato Rilana Martinato

    Hi i tryed several php code provided on github to do what you did with the plugin. And I am so happy to finaly found the plugin and it even works for me. I always run into the aouth problem… anyway is there a way I can extend the memory upload? I would really appreciate your answer. Thank you!

    • Andrew

      That’s to do with your server settings I believe.

      • http://www.facebook.com/rilana.martinato Rilana Martinato

         sure? I tryed 2 different servers. This is the error that I get by uploading.
        Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 662124 bytes) in/home/rilanab/public_html/wordpress/wp-content/plugins/dropbox-plugin/dropbox.php on line434

  • Chris

    Hi there great plugin, only issue I’m having is that I’m trying to host pdf files and was wondering if displaying these in the browser rather than downloading them would be possible?

  • Jamie Roberts

    Hi,

    Firstly, thanks for developing this plugin, it’s a massive help to me. I’m hoping to use it in a project for a client and the features are nearly right. I’d want to be able to see the thumbnails of images and then be able to tick multiple images and download them as a batch.

    I have budget from the client (though it’s not huge) so I should be able to fund a little bit of dev work. I have no idea how much time this might take you but I’d love to hear back, you can get me at jroberts@nts.eu.com

    Again, thanks for the great work so far!

    Thanks

    Jamie

  • Tarek G.

    Hi everyone,

    Thank you Andrew so much for this amazing plugin. I did tests and spend some time on it, and read a lot, but got it to work perfectly the way I wanted after about 2-3 hours of fooling around.

    I think that a sample shortcode would be greatly helpful for everyone, so here’s what I used to classify the information:

    [dropbox home="/Companies/Companyname/Accounting" hometext="Début" separator="/" allownavigate="true" allowdownload="true" columns="INDS" dateformat="F j, Y à h:i:s A" orderby="date" ordering="false"]

    I attached the result for the demo. I’m using the Twenty Twelve theme, so no need for a full screenshot. You can point your home=”/…” to whatever you like in Dropbox and have people access only that folder.

    I realize that people can’t access all the files in Dropbox, except where the home=”/…” points, so that is incredibly powerful if you know how to use it. You can a page per client and link it to a Dropbox folder.

    Andrew, you made my day man. I’m definitely donating by the end of the week!! Thanks again!!

    • Tarek G.

      Oops, here’s the screenshot of the result. :-)

      • Tarek G.

        Also, Andrew, where should I look to change the “February” to another language? I’m interested in French. Thanks!

        • Andrewsaccount

          I’m glad you find the plugin useful. Until I patch it in, probably this week or next week, here’s what you can do:

          Open up tdp_main.php and find this line

          case “D”:$output.=”".time($dateformat,$item["modified"]).”";break;

          and change it to

          case “D”:$output.=”".strftime($dateformat,$item["modified"]).”";break;

          A few lines above, add

          setlocale(LC_TIME, “fr_FR”);

          before the foreach loop.

          You’ll also need to change the dateformat tag based on the new function. More info here: http://php.net/manual/en/function.strftime.php

          Let me know if you have other questions.

        • Andrewsaccount

          sorry about that, the line should be “case “D”:$output.=”".time($dateformat,$item["modified"]).”";break;”

  • http://www.facebook.com/xiongtx Tianxiang Xiong

    Hi Andrew,

    I think your app is great, it’s the first that’s done what I want: allow visitors to browse through files right in my page.

    I’d like to make two suggestions, however:

    1) Add some more icons so the user can better differentiate between different file types.

    2) In the “TDP Options” page, allow the user to choose default settings for the various available options. For example, right now the default column option is INDSD, and I don’t need to show the date twice every time.

    Big thanks to @e398eeaacdc3079b9a3df1be04d618be:disqus for putting up the sample shortcode. I’m afraid that the instructions weren’t too clear. Might you consider integrating some of the information from the comment section into the FAQ?

    • Andrew

      You can already add your own icons. From this page: “In order to add icons place files in the ‘images’ folder(located in the plugin folder). File names must be ‘[extension of file].png’. For example ‘txt.png’ will be used as the icon for all *.txt files, ‘folder.png’ will be used for folders, and ‘default.png’ will be used for everything without a match.”

      I’ll add all the relevant info to the Options page because this FAQ is horrible :) and remove the second date from the default and update soon with a few more changes.

  • Tom

    There is an uncaught exception if the home folder doesn’t exist. Normally I wouldn’t ever add a link to a folder that didn’t exist but since this plugin works with Dropbox, it should be expected that folders may move around or be deleted in dropbox resulting in a Fatal Error being displayed on your website rather than a graceful error. This also reveals the full path to the plugin and other files within WP. Sample partial output…. “Fatal error: Uncaught exception ‘DropboxException’ with message ‘Path ‘/publicx’ not found’ in” If the folder doesn’t exist anymore a clean error should be displayed.

    • Andrew

      Thanks for pointing that out. Will fix :)

      • Tom

        Same thing happens if you try to link to a file that no longer exists. If in the off chance you try to link to the dropbox file i.e. http://my.website.com/pagename?g=/sample.jpg and sample.jpg no longer exists, the same Fatal Error shows. Thanks by the way…liking the plugin…hoping to LOVE it.

  • Tom

    Where did my previous comment go? I asked, how to have a ‘pretty’ error show if I move or delete a folder from Dropbox and fail to update the home path in the short code which results in a Fatal Error message.

    • Tom

      Boo hiss….I didn’t reload the page and thought my previous comment was killed. Please disregard this comment.

      • Andrewsaccount

        I’ve noticed that comments aren’t always displayed chronologically so it could be a mix of the two. I’ll have to dig around in the disqus settings.

  • Luigi

    Thank you Andrew. It’s a fantastic plugin and works perfectly for my customer.
    I will make a donation newt week!

    Thanks!

  • Luigi

    Hi Andrew,

    is it possibile to add a link like “Download all” ?
    I’d like to download all files within a folder in a zipped archive…

  • Luigi

    Hi Andrew,

    is it possibile to add a link like “Download all” ?
    I’d like to download all files within a folder in a zipped archive…

  • Mitch Menghi

    Hi Andrew, this seems like a cool plugin and im willing to donate, but before i try this, i want to use this for my clients to upload their files, however i do not want everyone to see each others files, is there any sort of permissioning i can add ? for Example FOLDER 1/ only available to a certain wordpress user FOLDER 2/ only available to client 2 etc… possibly even adding the option of selecting what folder are viewable to for each WP user would be fantastic ??? What do you think

    • Andrew

      You can place multiple tags customized to each user on individual pages/posts and either use the built in wordpress permissions or use another plugin to restrict user access to those pages.

      For example page1 has a folder1 embedded into it, and page2 has folder2 embedded into it. By allowing user1 to view page1 but not page2, you’re effectively restricting that user to folder1.

  • R0b1et

    Hi, this plugin is great, works like a charm, but is there a way to generate new folders within the dropbox system from my website? That will certainly help keeping things neat and tidy.