<commit_before><?php

namespace NFC\UploadBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\Image;

class UploadController extends Controller
{
    private $uploadFile = null;

    public function uploadAction()
    {
        $request = $this->get('request');
        $this->uploadFile = $request->files->get('file');
        if (is_null($this->uploadFile)) {
            die('File not found!');
        }

        $data = array(
            'success' => false,
            'error' => 'Upload error'
        );

        if ($this->uploadFile->isValid() && ($request->get('secure_token') === $this->get('session')->get('secure_token'))) {

            $filesConfig = $this->container->getParameter('file_upload.types');
            $fileSettings = $filesConfig[$request->get('type', 'default')];
            $sessionAttr = $request->get('field');
            $siteWebDir = $this->container->getParameter('file_upload.web_dir');
            $validator = $this->getFileValidator($fileSettings);

            if (!$validator) {
                $data = array(
                    'success' => false,
                    'error' => 'To upload files on a website, you need to have JavaScript enabled in your browser'
                );

                return new JsonResponse($data);
            }<commit_msg>fix controller<commit_after><?php

namespace NFC\UploadBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\Image;

class UploadController extends Controller
{
    private $uploadFile = null;

    public function uploadAction()
    {
        $request = $this->get('request');
        $this->uploadFile = $request->files->get('file');
        if (is_null($this->uploadFile)) {
            die('File not found!');
        }

        $data = array(
            'success' => false,
            'error' => 'Upload error'
        );

        if ($this->uploadFile->isValid() && ($request->get('secure_token') === $this->get('session')->get('secure_token'))) {

            $filesConfig = $this->container->getParameter('nfc_upload.types');
            $fileSettings = $filesConfig[$request->get('type', 'default')];
            $sessionAttr = $request->get('field');
            $siteWebDir = $this->container->getParameter('nfc_upload.web_dir');
            $validator = $this->getFileValidator($fileSettings);

            if (!$validator) {
                $data = array(
                    'success' => false,
                    'error' => 'To upload files on a website, you need to have JavaScript enabled in your browser'
                );

                return new JsonResponse($data);
            }
{'fraction_non_alphanumeric': 0.14503558115892917, 'fraction_numerical': 0.0, 'mean_word_length': 2.4893617021276597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3079212', 'n_tokens_mistral': 776, 'n_tokens_neox': 764, 'n_words': 155}