private function autoNumberFile($path, $file)
    {
        $extension = $file->getClientOriginalExtension();
        $original_name = $file->getClientOriginalName();
        
        $filename = $original_name; // Set to original name
        
        $counter = 1;
        while (file_exists($path . '/' . $filename)) {
            $filename = str_replace("." . $extension, '_' . $counter . "." . $extension, $original_name);
            $counter++;
        }
        
        return $filename;
    }