Allow Anyone To Upload Files To Your Dropbox Folder

Dropbox does not provide any functionality to allow other users to upload files to your account. This is a serious nuisance considering how may times we come across situations where we need users or co-workers to upload files so we can check them out. Such a functionality can also be useful when students or professionals are working in groups and everyone needs to upload files to one single directory.

Jake Jancar has created a simple PHP class, called Dropbox Uploader, which can be used to upload files to Dropbox. Reader Amit Banerjee has created a full script, which once uploaded to the server, can allow users to upload files to your Dropbox folder via a simple browser based uploader.

We played around with the script too and made a Dropbox Uploader with a neat interface (demo), and it worked!

Stuff My Dropbox

Before you upload the Dropbox folder containing the script to your server, edit the Index.php file with notepad, and provide your Dropbox email, password, and folder (where you want files to be uploaded). That is all!

email and password dropbox


dropbox folder name

For the complete step-by-step guide, along with the screencast, visit the blog post written by Amit Banerjee. You can also grab his script or grab ours (modified to look appealing) from the link below.

Download Dropbox Uploader script

Thanks to Jake Jancar for the original PHP class!

Update: If you have implemented some new features in the script for added security or better usability, we would be glad if you can share them with us (and the world) in the comments.

Update 2: Use DropItToMe, it is based on this script and includes password protection.

Advertisement
  • http://www.rhinetech.com RhineTech

    My only concern is if you have someone stumble across the page, or a ‘friend’ who wants to play a joke on you… all they have to do is upload a ton of stuff to fill up your hard drive on your system…

    This is the only reason I’m not jumping aboard…

    • http://www.ampercent.com Amit

      True but you should use it among your close and trusted friends and if someone tries to fill your hard drive with unwanted files, simply rename the webpage to some other name.

      I am trying to implement password protection on the script, will update in the comments when I am done.

      Thanks

      • Maarten

        Nice, script Amit!

        Ive changed it so that there is now a file filter, which filters out bad files if you turn it on.
        You can also make it use only files on a whitelist.

        The next thing I’m going to add is a spam blocker, if the same IP-Address uploads more than 5 things in less than 5 minutes, it wont allow him to upload anymore.

        • http://www.ampercent.com Amit

          Wow that’s cool Maarten

          But I think using a File whitelist isn’t always a good idea to block spammers. Password protection will be neat though.

          Can you share the changes and your script with us ?

          Thanks

          • Glenn Jackson

            Great job!

            I have many things in store for this and some I’ve already implemented. In Chrome this doesn’t render properly but I’m looking into tweaking that myself.

            Thanks.

    • http://www.ampercent.com Amit

      I have updated the script and added support for password protection. You can download the new script here http://www.ampercent.com/downloads/dupass.rar

  • Steve

    Excellent! When this gets password protection I’ll definitely be using it.

    Any timescale on when that will be implemented, please?

    Oh, and thank you!

  • Rolf

    Just that you know: There is a little error (double “) in the index.php HTML

    background-image:url(images/upload-btn.png)”;”

    Thank you for the post!

  • Kevin

    Any PHP4 friendly version of this code?

  • http://dropbox.com N. N.

    HELLo!

    Just wanted to point out that since this script uses Jake’s PHP class, it relies upon scraping the web interface. Since he released that class we’ve released the API, and as such recommend that people use this instead.
    The website is subject to change at any time, and when we do it’ll break the script. Using the API will prevent the script from breaking, even if we completely hose the web interface.

    Happy syncin’!

    • Steve

      It’s good to see someone from Dropbox commenting on this. Thank you.

      So, if this is liable to break, can you recommend a script with the API in mind instead?

  • davv

    Parse error: syntax error, unexpected ‘{‘ in /www/dropbox/index.php on line 32

    i can’t see what’s wrong here… any ideas ?

  • Steve

    Maybe this is helpful to the PHP coders here?

    http://code.google.com/p/dropbox-php/

  • http://www.matsumpter.com/ Mat

    I have updated the addictive tips version to add password protection, email upon upload, and moved from using DropboxUploader.php to the official API via OAuth. To make this more portable I have added the required PEAR libraries.

    Since this uses OAuth each install will need to sign up and generate API keys via https://www.dropbox.com/developers/apps

    http://173.192.163.34/stuff_my_dropbox.zip

    • http://www.addicitivetips.com Nakodari

      Hey thanks! I will have to write a whole new post on this one. Looks good so far…

      • http://www.matsumpter.com/ Mat

        The password prompt could use some graphic love but I am far from a graphic designer. Also the need to create the keys via the Dropbox developer tools can be a hassle for a normal user. But then again how many normal users are able to install a PHP script into a web site? :)

        • Colorado Teche

          Mat rocks!

          I updated Mats code with my changes and made a complete zip:

          http://dl.dropbox.com/u/8328259/stuff_my_dropbox.zip

          Changes:

          Added a few more instructions in the config section of index.php
          Added $strCertLocation to config section (for custom cert issues)
          Added $strUploadDirOnHost to config section (for custom cert issues)
          Added set_include_path( get_include_path() . PATH_SEPARATOR . “PEAR”); to config section (for those that might be having PEAR problems)

          Added “PEAR” directory with “Exception.php” in it

          Moved the email feature to be inside the try/catch statement

          Modified the css so the “Password” word is white.

          Thanks!

          • Colorado Teche

            Update #2: I added the tokens code to the config section with basic instructions on how to get them… once you put the tokens in you can remove your username/password.

  • Crazyhunk

    this is a really good script…
    though I do have a major concern… if someone looks at the source… he is bound to get my email and password to login… wouldn’t this be a huge risk… or is there a work around for this..

    I posted this on Amits blog as well…. just so more people can think and find an answer ..

    Thank You

    • http://www.matsumpter.com/ Mat

      When using the OAuth version I posted earlier you can just store the token that is used after it checks your username and password and just pass that in without always using your details.

      I’ve got some thoughts for how this could be rolled into a service where a user comes to the site and signs up. During the process they give a shortname used for a subdomain (mat.domain.com) and the OAuth happens and only the token is stored. From there they could set a upload password or other settings. My gears are turning about this :)

  • Steve

    @ Mat

    Thank you *very* much for this! But, there’s a problem :( I’ve just installed this and tried it out by uploading two images and both get corrupted somehow.

    Any ideas?

    • Sven

      I can reproduce Steve’s corrupted file problem with Colorado Teche’s modification and JPG & PDF files. Files are transferred to the defined inbound folder but you cannot open them (MD5 checksum is different so something happens on the way).

      • Glenn

        I have the same corruption issue with images. PDFs just won’t upload. Everything else I’ve tested, from text to compressed files uplaods fine.

  • http://dropbox.kingofcomedy.de/ Thorsten

    Hi,

    I have just released Version #4 of my dropbox-upload-script. You can send files to your dropbox via a normal link too. A feature which I wanted to have in a script but I have never seen it yet so I did it myself. :)

    • Steve

      Hi there,

      Where’s your script available from? Also, does it cure the problem with corrupt images?

      Thank you.

      • Thorsten

        And by now I didn’t have any problems uploading images, pdf-files, etc.

      • Sven

        Hi Steve,

        Thorsten’s script doesn’t have this problem with corrupted files as it doesn’t use the PEAR package.

  • Thorsten

    The link got deleted from my posting. ;) http://dropbox.kingofcomedy.de

    • Steve

      Thanks for this again Thorsten.

      Is there any chance you could update this to using the official API via OAuth because as “N.N” said above, it’s liable to break without that :(

      Or could you or someone (the original authors?) change the version by Mat or Colorado Teche so that those versions don’t corrupt images etc.?

      Thank you.

      • Glenn

        Doing so would require the user to be able to install php extensions which some may not have the ability to do. I’m looking into porting it now though for those of us that can.

        • Glenn

          Ok, so using the oauth php extension does indeed fix the corrupted images but I’ve just discovered that I cannot upload any filename with a space without it spitting back an error. If I can figure this out I’ll post a workaround.

    • Sergiu

      Hello. i have tried to use your script ” upload files to dropbox folder”, but all the time I receive the same error: “Cannot create temporary directory!”. I have noticed that a lot of people have the same problem. Could you please help me with this situation?
      Thanks

  • http://erik.happaerts.be Erhapp

    A progress bar while uploading would be nice.

    Any ideas how to implement this?

    • Steve

      @Erhapp

      Which version are you using? Are you having the problem with corrupt images?

      • http://erik.happaerts.be Erhapp

        I’m using Amit’s original version with Addictivetips interface (redone with divs instead of tables) and e-mail module transplanted in it.

        I tried Mat’s version but this version had indeed some trouble with corrupt images.

        The version of Colorado Techie didn’t work for me. The script kept telling met that the upload was successful but the files didn”t show up in Dropbox.

        • Glenn

          The version I just posted has been thoroughly tested and has no corrupted images and I’ve had no issues with uploading.

  • Glenn

    Apparently the original version has issues with spaces in the filename as well – it just parses an ambiguous error as a result. The PEAR library, while portable, corrupts images of any sort be it jpg, png or even pdf. Either way, I repacked it with some minor tweaks with the only major change being that you have to have the php oauth extension installed which can be found here:

    http://pecl.php.net/package/oauth/1.0.0

    I used pecl to install it and then restarted apache and now I can upload without fear of corruption.

    I did this in haste so if there any issues let me know and I will accomodate.

    http://dl.dropbox.com/u/4486296/dure-repack.zip

    • Steve

      I’d really like to use this but I have no idea how to install the oauth extension :(

  • Glenn

    Download the package from the above link, and assuming you’re using a sudo environment, run:

    sudo pecl install oauth-1.0.0.tgz

    Next, add the following line to both /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini:

    extension=oauth.so

    Finally, restart apache:

    /etc/init.d/apache2 restart

    If all goes well, you should be able to run the repack fine now.

  • http://www.daubler.ro andy

    does anyone know how to convert this code for a html website?

  • Mike

    Can someone make a version that doesn’t need the php oauth extension installed and that doesn’t corrupt images please?

    • Glenn

      It’s an issue with the dropbox api. There is a bug report on it and until that’s resolved you either have to use the php extension or the original version that doesn’t use the api.

  • http://www.filesdirect.com/Overview.aspx Frank

    I prefer FilesDIRECT:
    i. Send files up to 2GB even with free plan
    ii. Works with all file types (video, audio, CAD, whatever)
    iii. 128-bit SSL encryption on all files
    iv. No software to install, works with any OS and includes a free customizable drop box
    v. 2 GB of storage to start

    Easy to use, 30-day free trial – it’s got my vote!

  • Thorsten

    I have just uploaded version 0.6 of my script. New "features": Multi-File-Upload, Filesize-Limit, etc. http://dropbox.kingofcomedy.de/

    • http://thezapbox.com Martin

      Thanks so much Thorsten,

      The idea of URL uploads is fantastic because if you combine it with Hazel (mac Software) it means that I can trigger torrent downloads on my desktop computer from my iphone.

      The only problem is that all torrent files are uploaded corrupted. I’d really appreciate it if you could try to resolve that – to the extent that I’ll gladly donate money for your effort.

    • Herv

      any chance of a progress bar or basic animation that indicates that its uploading?

      Thanks for the script so far!!

  • http://www.slurm23.co.cc slurm23

    is it just me, or does the upload-button look somewhat distorted? i think the png-graphic has to be changed! maybe the original authors of the graphical interface could take another look…

    and while at it – is there a way to display how much free space is left in the dropbox? that would be awesome, too!

    • Glenn

      My version linked above uses the php extension but if you grab the images and css I tweaked the button image so it’s no longer distorted.

  • Mike

    Someone’s released a Dropbox (wrapper-)class to communicate with the Dropbox-API through PHP.

    It’s stand-alone, no PEAR-stuff required.

    http://forums.dropbox.com/topic.php?id=24758

    Could someone use this to create a new Dropbox uploader, please?

  • Jeff

    Whenever I try and upload a larger file, I get the error “Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 5508203 bytes) in /var/www/HTTP/OAuth/Consumer/Request.php on line 217″…

    Any help with this?

  • http://dropitto.me/ DROPitTOme

    There is now a free service based on this lovely script:

    DROPitTOme – Securely receive files from anyone to your Dropbox.

    http://dropitto.me/

    Happy Dropboxing!

  • Pingback: DropItToMe Is Secure Way To Let People Upload Files To Your Dropbox

  • scott

    Not sure if you can help me but I installed the scripte from addictive tips and the css is not rendering?
    any idea why?
    http://satori-design.com/Dropbox/
    scott

  • Thomas

    Small files under a 1 meg work great! You might as well just email them at that point if you ask me! Larger files like mp3s don’t really work very well at all or at all! I have alot of people send me large audio files to my dropbox, and this script doesn’t seem like it wouldn’t be very dependable!

  • Dan Kirshner

    As of about March 9, 2012, Dropbox changed the login form — it no longer requires (or has) the token “t”.

    So DropboxUploader.php needs the following change (comment out line 86, set $token to null):

               //$token = $this->extractToken($data, ‘/login’);
               $token = “”;

  • Coastalcutthroat14

    Is their an Alternative NON-Php method?

    JotForm’s free account restricts uploads to 100MB.

    I’ve got a form and it must allow anyone to upload straight into my Dropbox account.

    Thanks!!!

  • Andriuz1

    It does not work for me. It shows me this message: Error: Cannot extract token! (form action=/login) help please…

    • Dan Kirshner

       Make the following change (comment out line 86; then set $token to null):

                 //$token = $this->extractToken($data, ‘/login’);           $token = “”; 

      (per my comment on approx. 11 Mar 2012)

  • Daniel

     Error: Cannot create temporary directory!

    Can somebody help me please?

    • on3php

      did you get a answer on this – having the same problem

  • almaue1963

    can script be added to the uploader so an email can be sent to the “receiver” that a file has been uploaded?

  • http://www.facebook.com/scott.smith.14268 Scott Smith

    we are getting the error of Error: Login Unsuccesful even though we know our credentials are correct. Any ideas?

    • http://www.facebook.com/people/Ravindr-Kr/532751650 Ravindr Kr

      I’m getting the same error message. Were you able to solve the issue. I’m using v9. The earlier version is working fine but it is throwing error for big files.