Hi All. First of all, this is an awesome plugin. Thank you very much! I am also needing to upload to multiple folders (all subfolders of the folder I specified in the plugin’s settings).
I’ve managed this by adding the following code in the wp_dropbox.php file around line 95 (note that the first two lines are part of the pre-existing code):
$wpsdb_up_method = get_option('wpsdb_php_pear');
$wpsdb_path = get_option( 'wpsdb_path' );
/* User defined Subdirectory and Custom Renaming Attributes */
extract(shortcode_atts(array('subdir' => NULL, 'rename' => NULL), $atts, 'simple-wp-dropbox'));
if ($subdir != NULL){
$wpsdb_path .= $subdir.'/';
}
/* end user-defined subdirectory, etc. */
Additionally, because I need the resulting files to have particular names (though not the original file names), I included this code further down around line 276 (again, first two lines are the original, pre-existing code)
$wpsnew_file_name = explode(".",$file['name']);
$wpstmpFile = $wpsdb_tmp_path.'/'.str_replace("/", '_', $wpsnew_file_name[0]) . "_" . rand(1000,9999) . "_" . date("Y-m-d") . "." . str_replace("/", '_', end($wpsnew_file_name));//$wpsnew_file_name[1]);
/* Renaming file based on custom user-defined input */
if ($rename != NULL)
$wpsnew_file_name[0] = $rename;
$wpstmpFile = $wpsdb_tmp_path.'/'.str_replace("/", '_', $wpsnew_file_name[0]) . "." . str_replace("/", '_', end($wpsnew_file_name));//$wpsnew_file_name[1]);
/* end renaming */
Now I can use the shortcode like this:
[simple-wp-dropbox subdir=”My-Custom-Subdirectory” rename=”my-custom-name”]
Now I can use different pages on my site to upload to different subfolders or (as is the case) define the subfolder dynamically through a PHP variable.
Both variables remain optional but adding the second code snippet does short-circuit the default renaming so don’t insert that part without considering that.