PHP code example of anatoliynyatin / far-symfony2-jquery-upload

1. Go to this page and download the library: Download anatoliynyatin/far-symfony2-jquery-upload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anatoliynyatin / far-symfony2-jquery-upload example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new faparicior\FARSymfony2UploadBundle\FARSymfony2UploadBundle(),
        );

        // ...
    }

    // ...
}

/**
 * @Route("/save/{id_session}")
 * @Method("POST")
 *
 * @param string $id_session
 *
 * @return JsonResponse
 */
public function saveAction($id_session)
{
    $php_session = $this->get('session')->getId();
    $FARUpload = $this->get('far_symfony2_upload_bundle.far_symfony2_upload_lib.service');

    $files = $FARUpload->getListFilesLocal($php_session, $id_session);
    $files = $FARUpload->setListFilesPathRemote($files, $id_session);

    $files = $FARUpload->syncFilesLocalRemote($files, true);
    $files = $FARUpload->deleteFilesLocal($files);

    return new JsonResponse(array('files' => $files));
}
bash
$ php app/console debug:router

farsymfony2upload_default_upload POST        ANY    ANY  /farupload/upload/{id_session}
farsymfony2upload_default_delete POST|DELETE ANY    ANY  /farupload/tmp/{php_session}/{id_session}/{image}_{action}