Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create uploads subfolder
#1
I've tried to do my first plugin. It should allow to create new folder. but obviously it'doesen't work. i've modified the Hello world plugin to start...
This is the code:

Code:
<?php
/*
Plugin Name: Create Folder
Description: Create a new directory in the upload folder
Version: 1.0
Author: Enrico
Author URI: -
*/

# get correct id for plugin
$thisfile=basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,
    'Create Folder',    
    '1.0',        
    'Chicco',
    'http://www.cagintranet.com/',
    'Finds email addresses in content and components and "hides" them',
    'theme',
    'hello_world_show'  
);

# activate filter
add_action('files-sidebar','Create_Folder');



# functions
function Create_Folder() {
global $dir;
global $result;

echo '<form class="fullform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">
<p><input type="text" name="dir" id="dir" /></p>
<input type="hidden" name="hash" id="hash" value="$SESSIONHASH" />
<p><input type="submit" class="submit" name="submit" value="Cartella" /></p>';
if($result!=NULL){echo $result;}
echo'</form>';
if($dir!=NULL){
    $dir=$_REQUEST['dir'];
    if(!mkdir('GSDATAUPLOADPATH/'.$dir,0777)){$result='Not working';} else{$result='Working';}
    }
    return $result;
}

?>

I would create a plugin that allow to upload images in the subfolder you chioce.
Cheers
Reply




Users browsing this thread: 1 Guest(s)