Ok ok... rs

Primeiro:
 - colocar o var $components = array("Upload");

Segundo:
 - no view crie um campo file normal, por exemplo:
   <input type="file" name="arquivo1">

Terceiro:
 - na hora de receber esse arquivo no controller:
  $this->Upload->setPath("imagens"); // considerando esta pasta dentro
de webroot que recebera o arquivo
  $this->Upload->copyUploadedFile("arquivo1",
"nomedoarquivonoservidorSemExtensao"); // vai retornar true se o
arquivo foi copiado com sucesso! olhar a extensao se ela está na lista
de permitidas, vide $allowedExtensions no component.

Prontex!

Espero ter ajudado..

Abraços...


On 20 ago, 16:37, hostdesigner <[EMAIL PROTECTED]> wrote:
> Ou eu sou muito burro e não entendi nada do que você disse ou eu sou
> muito burro e não entendi nada do que está escrito no script :D
>
> Preto no branco:
> Não consegui usar isso até agora. Já mexi de tudo quanto é jeito e
> nada de upload.
>
> Vamos lá, tutorial inverso (existe isso?)
> Eu criei 3 campos do tipo file, nome-ei-os como "file0", "file1" e
> "file2"...
>
> E no controller eu coloco:
>
> $this->Upload->copyUploadedFile( "file". $i ."", $this->params['file'.
> $i ] );
>
> ou coloco
>
> $this->Upload->copyUploadedFile( "file". $i, "file". $i );
>
> Tentei das duas formas e nada...
>
> Explica ai direitinho.
>
> Falopa!
>
> On 17 Ago, 22:18, Tulio Faria <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Você informa só o nome do campo (igual tá no html)...
>
> > []'s
>
> > On 17 ago, 20:37, hostdesigner <[EMAIL PROTECTED]> wrote:
>
> > > Um legal, mas, me diz uma coisa como você informa o nome do arquivo?
>
> > > $this->params['form']['File']
>
> > > É isso?
>
> > > Falopa!
>
> > > On 17 ago, 18:44, Tulio Faria <[EMAIL PROTECTED]> wrote:
>
> > > > Pra usar:
> > > > $this->Upload->setPath("img/images/");
> > > > $this->Upload->copyUploadedFile("campofiledoform", "nomedoarquivo");
>
> > > > abraços,
>
> > > > On 17 ago, 19:42, Tulio Faria <[EMAIL PROTECTED]> wrote:
>
> > > > > Eu fiz um component para isso:
> > > > > (ta sem comentário...)
> > > > > <?
> > > > >     class UploadComponent extends Object{
> > > > >         var $controller = true;
> > > > >         var $path = "";
> > > > >         var $maxSize;
> > > > >         var $allowedExtensions = array("jpg", "jpeg", "gif");
>
> > > > >         function startup(&$controller){
> > > > >             $this->path  = APP.WEBROOT_DIR.DS;
> > > > >             $this->maxSize = 2*1024*1024; // 2MB
> > > > >         }
>
> > > > >         function setPath($p){
> > > > >             if ($p!=NULL){
> > > > >                 $this->path = $this->path.$p;
> > > > >                 $this->path = eregi_replace("/", DS, $this->path);
> > > > >                 $this->path = eregi_replace("\\\\", DS, $this->path);
> > > > >                 return true;
> > > > >             }
> > > > >         }
> > > > >         function setMaxFileSize($size){
> > > > >             $this->maxSize = $size;
> > > > >         }
> > > > >         function addAllowedExt($ext){
> > > > >             if (is_array($ext)){
> > > > >                 $this->allowedExtensions = 
> > > > > array_merge($this->allowedExtensions, $ext);
>
> > > > >             }else{
> > > > >                 array_push($this->allowedExtensions, $ext);
> > > > >             }
> > > > >         }
> > > > >         function getExt($file){
> > > > >             $p = explode(".", $file);
> > > > >             return $p[count($p)-1];
> > > > >         }
> > > > >         function copyUploadedFile($source, $destination){
> > > > >                     $pass = false;
> > > > >             if (is_uploaded_file($_FILES[$source]["tmp_name"])){
> > > > >                  if ($_FILES[$source]["size"] < $this->maxSize){
> > > > >                     if (count($this->allowedExtensions)==0){
> > > > >                                                                 // 
> > > > > dont make validation
> > > > >                                                                 $pass 
> > > > > = true;
> > > > >                     }else{
> > > > >                                                                 // 
> > > > > make validation
> > > > >                                                                 $pass 
> > > > > = false;
> > > > >                                                                 
> > > > > foreach($this->allowedExtensions as $ext){
> > > > >                                                                       
> > > > >   if (eregi(".*".$ext."$",$_FILES[$source]["name"])){
> > > > >                                                                       
> > > > >           $pass = true;
> > > > >                                                                       
> > > > >   }
> > > > >                                                                 }
> > > > >                                                   }
> > > > >                  }
> > > > >                                           if ($pass){
> > > > >                                                         // make upload
> > > > >                             $ext = $this->getExt($_FILES[$source]
> > > > > ["name"]);
> > > > >                                                         
> > > > > move_uploaded_file($_FILES[$source]["tmp_name"], $this->path.
> > > > > $destination.".".$ext);
> > > > >                                           }else{
> > > > >                                                         // dont make 
> > > > > the upload
> > > > >                                           }
> > > > >             }
> > > > >         }
>
> > > > >     }
> > > > > ?>
>
> > > > > On 16 ago, 12:53, hostdesigner <[EMAIL PROTECTED]> wrote:
>
> > > > > > Como eu resgato o nome e nome temporário do arquivo no cake?
>
> > > > > > Eu consigo resgatar o nome do arquivo assim,
>
> > > > > > $this->params['form']['meu_campo']
>
> > > > > > Só que desta forma aparentemente não tenho aceso ao handler para 
> > > > > > poder
> > > > > > manipular o arquivo, somente o nome do arquivo está disponível.
>
> > > > > > Alguém tem solução?
>
> > > > > > Falopa!


--~--~---------~--~----~------------~-------~--~----~
Recebeu esta mensagem porque está inscrito em Grupo "Cake PHP Português" do 
Grupos Google.
 Para enviar mensagens para este grupo, envie um email para 
[email protected]
 Para anular a inscrição neste grupo, envie um email para [EMAIL PROTECTED]
 Para mais opções, visite este grupo em 
http://groups.google.com/group/cake-php-pt?hl=pt-PT
-~----------~----~----~----~------~----~------~--~---

Responder a