Welcome Guest, Not a member yet? Register   Sign In
Can Upload Class create new folders?
#1

[eluser]diggersworld[/eluser]
Hello,

I've scoured the forums for this and so far found nothing, same goes for the user guide.

I was wondering if its possible for the Upload Class to dynamically create new folders for storing uploaded images to. Rather than just having an uploads folder which will eventually become very crowded.

If anyone knows of a way or can offer some alternate suggestions then I'm listening.

Regards,
Diggersworld.
#2

[eluser]loosetops[/eluser]
It wouldn't help for it to dynamically create folders. You would need the folders to follow a particular naming pattern and be created only when the current upload folder is filled to your requirements.

You can count the image files yourself

Code:
$dir = new DirectoryIterator('/path/to/dir');
foreach($dir as $file ){
  $x += (isImage($file)) ? 1 : 0;
}

if you are sure the directory contains only image files
Code:
$dir = new DirectoryIterator('/path/to/dir');
foreach($dir as $file ){
  ++$x;
}

Then you can use mkdir to create a new directory
#3

[eluser]diggersworld[/eluser]
Ah brilliant, just what I need.

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB