How to solve "Unable to create the "%kernel.root_dir%/../web/uploads" directory" error in Symfony2
<p>I'm working with a bundle to upload any type of file.<br>
For this purpose, I created a new bundle <em>uploadBundle</em> with the following files:</p>

<h3>Entity "Archivo.php"</h3>

<pre><code>&lt;?php

namespace SisEvo\UploadBundle\Entity;


use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
*/
class Archivo {

/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @ORM\Column(type="integer")
 */
private $idTipo;

/**
 * @ORM\Column(type="integer")
 */
private $idAgregado;

/**
 * @var File
 *
 * @Assert\File(
 *     maxSize = "50M",
 *     mimeTypes = {"application/pdf", "application/x-pdf, application/x-rar-compressed, application/octet-stream, application/csv, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/vnd.ms-excel"},
 *     maxSizeMessage = "El arxiu es massa gran",
 *     mimeTypesMessage = "El tipus d'arxiu seleccionat no està permitit" 
 * )
 */
protected $file;
</code></pre>

<p>Additionally, this entity contains <code>get</code> and <code>set</code>required methods, and finally, an <strong>upload</strong> method that looks like this:</p>

<pre><code>public function upload($file, $path = '%kernel.root_dir%/../web/uploads') {
    if (null === $file) {
        return;
    }
    $name = $file-&gt;getClientOriginalName();
    $file-&gt;move(
            $path, $name
    );
    unset($file);
}
</code></pre>

<h3>Form "ArchivoType.php"</h3>  

<pre><code>&lt;?php

namespace SisEvo\UploadBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;


class ArchivoType extends AbstractType {

/**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
    public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder
            -&gt;add('file', 'file')

    ;
}

/**
 * @param OptionsResolver $resolver
 */
public function configureOptions(OptionsResolver $resolver) {
    $resolver-&gt;setDefaults(array(
        'data_class' =&gt; 'SisEvo\UploadBundle\Entity\Archivo'
    ));
}


}
</code></pre>

<h3>Controller "UploadController.php"</h3>

<pre><code>class UploadController extends Controller {

    /**
     * @Route("/file_upload/" , name = "file_upload")
     */
    public function probarAction() {
        $request = $this-&gt;getRequest();

        $file = new Archivo();
        $formulario = $this-&gt;createForm(new ArchivoType());

        $formulario-&gt;handleRequest($request);

        if ($formulario-&gt;isValid()) {
            $em = $this-&gt;getDoctrine()-&gt;getManager();
            $data = $formulario-&gt;getData();
            $fileUploaded = $data-&gt;getFile();
            $file-&gt;upload($fileUploaded);

            echo "SUCCESS!";
        }
        return $this-&gt;render("upload/prova.html.twig"
                    , array("formulario" =&gt; $formulario-&gt;createView())
        );
    }

}
</code></pre>

<h3>The problem</h3>

<p>If the folder <code>/uploads</code> doesn't exists, this code works fine; this is, the first time that I use it, but the following times Symfony shows this error:</p>

<blockquote>
  <p>Unable to create the "%kernel.root_dir%/../web/uploads" directory</p>
</blockquote>

<p>And the error is produced in this piece of code in vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/File/File.php at line 110</p>

<pre><code>if (!is_dir($directory)) {
    if (false === @mkdir($directory, 0777, true) &amp;&amp; !is_dir($directory)) {
        throw new FileException(sprintf('Unable to create the "%s" directory', $directory));
    }
} elseif (!is_writable($directory)) {
    throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
</code></pre>

<p>It's seems like Symfony doesn't find <code>uploads</code> folders.
I tried to change permisions with chmod 777 -R, but the issue persists.
Any idea to solve this? 
Thanks in advance :)</p>

<p><strong>EDIT with more infomation</strong>  </p>

<p><strong>First</strong><br>
I am creating a service to upload files from any part of my application, so I created a bundle with an entity and a simple form. The controller post above it's only a proof, and when the <code>uploadBundle</code> will been finished, this controller will be deleted and  the upload method will be used in each part of the application that I need it.<br>
Furthermore, the code than store the information of each uploaded file in the database are not developed yet.  </p>

<p>Please, can you explain me why is wrong my architecture? Thanks :)</p>

<p><strong>Second</strong><br>
<code>Chmod</code> gets the octal 777 from the symfony kernel; code posted in the <strong>problem</strong> section is from symfony.  </p>

<p><strong>Third</strong><br><br>
You are right, the code doesn't works how as I expected. It create a folder inside web folder like this: <code>web/web/uploads</code>. I need to get more information about internal folders on Symfony. Anyway, @pablo 's answer solve my problem with this.</p>