title: creating a function for upload to save a specific path and check the limit of the folder
body: <p><strong>i have a function to upload a file(video,audio, images and documents)  .. but i cant think of how to continue it.. I'm a beginner in programming by the way. and i want to upload a file and check the limit of the folder where i want to save the file if the folder reached the limit of 10 000 file inside,  if  it is true then it will create a new folder that has the same name but has a number in it (folder,folder 1 will be the next created)  and save it to the folder created..</strong></p>
  
  <pre><code> function uploads($filename,$tempname){
  
        $errors= array();
        $file_name = $filename;
        $file_tmp = $tempname;
        $audioPath = "./archivestorage/upload/media/audio/";
        $videoPath = "./archivestorage/upload/media/video/";
        $imagePath = "./archivestorage/upload/media/images/";
        $documentPath = "./archivestorage/upload/document/";
        $file = pathinfo($filename,PATHINFO_EXTENSION);
        if(empty($errors)==true) {
  
  
  
                      if($file ==='jpg')
                      {   
                           move_uploaded_file($file_tmp,$imagePath.$file_name);
                           echo "Success";
                           $return = $imagePath;
  
  
                      }
                      elseif($file ==='mp4')
                      {
                           move_uploaded_file($file_tmp,$videoPath.$file_name);
                           echo "Success";
                            $return = $imagePath;
                      }
                      elseif($file ==='mp3')
                      {
                           move_uploaded_file($file_tmp,$audioPath.$file_name);
                           echo "Success";
                            $return = $imagePath;
                      }
                      elseif($file ==='jpeg')
                      {
                           move_uploaded_file($file_tmp,$imagePath.$file_name);
                           echo "Success";
                            $return = $imagePath;
                      }
                      else if($file ==='docx')
                      {
                           move_uploaded_file($file_tmp,$documentPath.$file_name);
                           echo "Success";
                            $return = $imagePath;
                      }
                      elseif($file ==='png')
                      {
                           move_uploaded_file($file_tmp,$imagePath.$file_name);
                           echo "Success";
                            $return = $imagePath;
                        }
                     else{
                   print_r($errors);
                      }
                      }
  </code></pre>