I need a little help. Im a newbie. I'm trying to create a php script for uploading files. Currently I'm using a static/fixed location for uploading. But I want to organize them according to year/ month folders. just like wordpress. here is the code I'm using $config['baseurl'] = 'http://mysite.com'; $config['path'] = $config['basedir'].'/uploads'; Code (markup): currently image path looks like: http://mysite.com/uploads/image.jpg but I want: http://mysite.com/uploads/2012/07/image.jpg I'll very appreciate if someone make me a little php code. Thanks
Well you can change the config path, but thats not handy if the script doesn't make the directory tree try this. $config['path'] = $config['basedir'].'/uploads'; if (!is_dir($config['path'])) { mkdir($config['path']); } // add YEAR to the PATH $config['path'] = $config['path'] . '/' . date("Y"); if (!is_dir($config['path'])) { mkdir($config['path']); } // add MONTH to the PATH $config['path'] = $config['path'] . '/' . date("m"); if (!is_dir($config['path'])) { mkdir($config['path']); } PHP: or something
Thanks dude, sure I'd like to make polls at my blog using your site it really helped, and also please let me know will it be creating directories automatically if year or month changes?