-3

Right now I am coding an website that will be used to upload and download images. I have an function that will upload the files but I don't how how to read how many there are in the folder and how to execute the createElement for each. All help is welcome...

Araknor
  • 13
  • 3
  • 2
    Your problem and statement is unclear. Please work on your English. – Denis Priebe Jul 19 '16 at 15:34
  • When someone uploads a file, store the path in a database and read from the database all the uploads. Then you can construct a list of the images on your web dynamically. – ManoDestra Jul 19 '16 at 19:07

1 Answers1

1

count images in your folder

$directory = '/var/www/ajaxform/';
$files = glob($directory . '*.jpg');

if ( $files !== false )
{
 $filecount = count( $files );
 echo $filecount;
}
else
{
 echo 0;
}
Artem Ankudovich
  • 458
  • 2
  • 14
  • With the addition of [this answer](http://stackoverflow.com/questions/17527713/force-browser-to-download-image-files-on-click) and you showing how to loop over the collection of `jpg` files (`foreach ($files as $filename) { ... }`), should make your example a complete solution. But still good enough for an upvote – Alon Eitan Jul 19 '16 at 15:55
  • Thanks helped me very much! – Araknor Jul 20 '16 at 11:20