Foros del Web » Programando para Internet » PHP » Symfony »

Subir archivos desde formulario

Estas en el tema de Subir archivos desde formulario en el foro de Symfony en Foros del Web. He seguido todos los pasos de este tutorial pero no consigo subir el archivo. http://symfony.com/doc/current/cookb...e_uploads.html y me sale lo siguiente. No entiedno porque......
  #1 (permalink)  
Antiguo 12/11/2011, 08:45
 
Fecha de Ingreso: marzo-2006
Mensajes: 230
Antigüedad: 18 años, 1 mes
Puntos: 2
Subir archivos desde formulario

He seguido todos los pasos de este tutorial pero no consigo subir el archivo.
http://symfony.com/doc/current/cookb...e_uploads.html y me sale lo siguiente. No entiedno porque...

  #2 (permalink)  
Antiguo 12/11/2011, 09:42
 
Fecha de Ingreso: marzo-2006
Mensajes: 230
Antigüedad: 18 años, 1 mes
Puntos: 2
Respuesta: Subir archivos desde formulario

Lo he hecho funcionar con un apaño pero es incorrecto...He puesto a piñon, tanto la direccion del servidor absoluta como la web y me funciona. De la siguiente forma...

Código PHP:
  public function getAbsolutePath()
    {
        return 
null === $this->path null $this->getUploadRootDir().'/'.$this->path;
    }

    public function 
getWebPath()
    {
        return 
'/miproyecto2/web/bundles/acmedemo/upload/Productos';
    }

    protected function 
getUploadRootDir()
    {
        
// the absolute directory path where uploaded documents should be saved
        
return __DIR__.'/../../../../web/'.$this->getUploadDir();
    }

    protected function 
getUploadDir()
    {
        
// get rid of the __DIR__ so it doesn't screw when displaying uploaded doc/image in the view.
        
return '/usr/local/zend/apache2/htdocs/miproyecto2/web/bundles/acmedemo/upload/Productos';
    }
    
    public function 
upload()
    {
        
// the file property can be empty if the field is not required
        
if (null === $this->file) {
            return;
        }

        
// we use the original file name here but you should
        // sanitize it at least to avoid any security issues
        // move takes the target directory and then the target filename to move to
        
$this->file->move($this->getUploadDir(), $this->file->getClientOriginalName());

        
// set the path property to the filename where you've saved the file
        
$this->setRutaimagen($this->getWebPath()."/"$this->file->getClientOriginalName());

        
// clean up the file property as you won't need it anymore
        
$this->file null;
    } 

Etiquetas: formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 12:41.