Get DropBox and Joomla! - Accept Files Without Email |
Do you want public upload for your DropBox? Do you want to allow people to send you files without email? Do you want to know how to integrate Joomla and DropBox? This article was created for you!
If you haven't seen it yet, DropBox is a very promising service that acts just like a server...except much much better.
- Files are stored locally AND on the web. This means faster access, and no risk of data loss.
- Synchronize files among as many machines as you want
- No waiting for file transfers...all work is done in the background
- Efficient data transfer; DropBox sends the delta (the part that changed) only. If you're working with large files (Photoshop files for example), this will really speed up the process
- Low cost (or even free) and no server maintenance.
But there's one thing that hasn't been solved yet... and that is the old "send the file to my email" routine. What a pain! Wouldn't it be nice to allow people to send files to you and/or your team DIRECTLY? And wouldn't it be even better to do this straight from your Joomla website? You can!
With a little modification of a generic DropBox upload script, this task is actually quite simple.
What you'll need:
- Comfort with basic changes to code (PHP and HTML)
- A DropBox account (Free or Paid version is fine)
- A Joomla website
- Installed ChronoForms component for Joomla (Free or Paid version is fine)
- DropBox Uploader (this tutorial written using v1.1)
What to do:
- Place the dropbox uploader (DropboxUploader.php) to the root of your website. (something like: http://www.example.com/DropboxUploader.php)
- In the Joomla Administrator, go to chronoforms and create a new form.
- Add the following to the "form tag attachment": enctype="multipart/form-data"
- Insert the following for the "form html" :<?php
if ($_POST) { require 'DropboxUploader.php'; try { // Rename uploaded file to reflect original name if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) throw new Exception('File was not successfully uploaded from your computer.'); $tmpDir = uniqid('/tmp/DropboxUploader-'); if (!mkdir($tmpDir)) throw new Exception('Cannot create temporary directory!'); if ($_FILES['file']['name'] === "") throw new Exception('File name not supplied by the browser.'); $tmpFile = $tmpDir.'/'.str_replace("/\0", '_', $_FILES['file']['name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $tmpFile)) throw new Exception('Cannot rename uploaded file!'); // Upload $uploader = new DropboxUploader("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
", "YOURDROPBOXPASSWORD"); $uploader->upload($tmpFile, "uploads-INSECURE"); echo '<span style="color: green">File successfully uploaded!</span>'; } catch(Exception $e) { echo '<span style="color: red">Error: ' . htmlspecialchars($e->getMessage()) . '</span>'; } // Clean up if (isset($tmpFile) && file_exists($tmpFile)) unlink($tmpFile); if (isset($tmpDir) && file_exists($tmpDir)) rmdir($tmpDir); } ?> <input type="file" name="file" /><input type="submit" value="Send Your File!" />
- Change the "
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
" and "YOURDROPBOXPASSWORD" to the login for your dropbox account
- You should also notice that uploads will be placed in the "uploads-INSECURE" folder. You can change this, but you should have something that alerts you that the file came from your website
- There is an option to change the "FORM URLS" in chronoforms. You will need to change the "SUBMIT URL" to the url to this same form. So, if you name your form "upload", the submit url would be: /index.php?option=com_chronocontact&chronoformname=upload
- Try it out!
Troubleshooting:
- If you don't see a "file successfully uploaded" or "file not uploaded" notice when you submit the form, then you need to make sure the "Form Urls" are pointed correctly (Step 5)
- File upload size is still limited by the capabilities of your webserver. You should contact your hosting provider to determine the maximum file size you can post by PHP
Other possibilities:
- Using the original uploader script, you could allow visitors to upload to their own dropbox accounts
- You may choose to force SSL to help ensure security of the uploads
- Password protecting your upload form may be important to reduce spam, or only allow trusted people to send you files
- Use the email to dropbox script to completely rid yourself of annoying file attachments!
|