plupload and RackSpace cloud files

Hi Guys,

There are a few uploaders that one can like. Mine favourite is plupload and there are heaps of reason behind that, but this post is not about discussing how good plupload is rather we will concentrate on how we can use plupload to upload files to your server and then send a signal to your server to upload that file to RackSpace cloud files.

This post assume that average file size to be uploaded is not more than few 100 kilobytes else a bit more sophisticated error handling will be required so that files are reliably sent to RackSpace Cloud.

You should know we will need to upload a file to the server hosting plupload and then upload it to RackSpace cloud. Doing it this way does have advantages as it offers greater flexibility.

Here is an activity diagram of what we are going to do. This is just a basic activity diagram explaining core steps only. You can have better error handling.

plupload and Rackspace cloud file activity diagram

Above is just a skeleton activity diagram. In the code provided the upload failure to RS Cloud is not implemented and I leave it to you to do that.

Lets get started.

Create a folder pltest under your htdocs or html folder. This is the location where your web server find files to return to the user when queried. On linux path could be


and on windows path could be something like this depending on where you’ve installed Apache.


Download plupload

First step is to download plupload and this can be done by visiting their website and follow the download instructions. Here is the link

Extract downloaded plupload in pltest folder.

Getting Cloud Files PHP API

Next we will need to download Cloud Files PHP API which you can find here

Extract PHP files in archive to to our pltest folder. Your folder structure should look like this now.

Folder structure for plupload test with Rackspace cloud files

Also make sure that you extract share folder under pltest. Sorry that is not part of the screenshot above as I extracted it later :)

Lets now create our test database with just one table. The commands are given below

Creating Database

I am also using a simple mysql database wrapper class that can be found here. This is not required but I use it for example projects. Makes things convenient a bit for me. but that’s a personal choice you know.

Lets now create a file called index.php under pltest folder. This file will have our pluploader. Content of this file are shown below

As you can see that we have created a uploader above that handles a few events. I am just allowing image files to be uploaded as you can see.

We are following our activity diagram in the above code.

These are the steps that user will take

  1. Select an image file to be uploaded
  2. User press “Upload Files” button
  3. The data is sent to upload.php script. Thanks to plupload guys for the script. I have just included database code in that script.
  4. Once the upload to local server is finished then “UploadComplete” event is fired and we send another script a signal to start sending our files to RS cloud.

You can do all sort of stuff. This is just a skeleton implementation and you can have more advanced implementation which allows far more greater flexibility. My Idea was to show you how you can use plupload and RS Cloud files together.

Lets take a close look at our UploadComplete event. As you can see that the data is being pushed to rsupload.php file. This script is responsible to upload New local uploads to RS Cloud.
Make sure that you update the following values before testing this mini implementation project

Also make sure that in that script please modify the container that you wish to use. Here are the lines

Database configs can be changed in dbconfig.php file

Download source

Source for this mini project can be download from the link below.

Remember that this is just a skeleton application to give you an Idea how to go about things. I could have made it a bit complex but then you may find it a bit hard to understand/grasp.

You should incorporate better error handling and session management, Also you should have a dedicated script that will reattempt to upload failed or incomplete uploads.


Database states

When user uploads a file to local server

After UploadComplete event is fired and When upload to RS Cloud is finished

Click above images to enlarge


Points that are important

  1. Make sure that you introduce a fallback handler just in case the upload to RS Cloud has failed for any reason. You should have Cron jobs setup to check periodically if a force upload is required.
  2. This is just a simple skeleton application, do not judge on the code rather this post was to show you ONE way to use plupload and RS Cloud together.
  3. You should have better error handling
  4. I am not updating all columns but rather I concentrated on important steps
  5. Make sure that you change database configs before you test out this project
  6. Make sure to use proper RS username and API key

This post will be improved over the time with feedback from you guys.

There are possibly many ways and individual preferences to deal with this concept. Not every possible way is preferred in a given scenario rather you should go about changing the project to suit what;s required in your application.

Final word

Please consider donations so that more mini projects like this can be done in future or to maintain the provided code


This is important bit. I generally fund my own stuff only except my Tea and Coke. So if you are interested donating a penny for my work. Consider donations! I don’t get many because generally people skip this part.   :) but its always worth asking.

Buy me a bottle of Ice Tea :)

$ 175.00 raised.
Choose donation amount:



I hope that this helps


VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)


  1. Jaspreet this tutorial worked perfectly. The only additional step I needed to make was to ensure write permissions on the “uploads” folder. Thanks so much for taking the time to write this article!

Speak Your Mind


CommentLuv badge