Through some reverse engineering of the Coppermine flash uploader, I built my own remote uploader for Coppermine that allows users to upload images from a different part of my website. I use bridging to authenticate my WordPress users with my Coppermine installation, so this is particularly useful for areas of my website where users want to add images without having to navigate to the gallery and then back to the page they were last on to add an image.
Essentially, the flash uploader sends a POST request to the upload.php file in your main gallery installation folder.
It sends the following variables:
- user (base 64 of serialised user_id and password_hash)
- album (album id)
- process (1)
- Filename (filename of uploaded image)
- [standard multi-part image data]
In response, it sends a single line of plaintext like follows:
success0|albums/userpics/10002/thumb_IMAG0061.jpg
To generate the user variable, you need to make a php array with a user_id and pass_hash variable inside from your authenticated user.
Then serialise the object and run it through base64_encode.
For example, with my WordPress bridged copy of Coppermine, I get the user variable using:
global $current_user;
get_currentuserinfo();
$coppermine_user_var = base64_encode(serialize(array(“user_id” => $current_user->ID, “pass_hash” => $current_user->user_pass)));
Best solution to implementing this is to look at the setup_swf_upload.js file inside of the Coppermine js folder.