Dotani Postado Setembro 9, 2008 Denunciar Share Postado Setembro 9, 2008 Pessoal Tudo bem...Estou com problema na passagem de parametros entre minha classe e um arquivo tpl, gerado pelo Smarty, estou iniciando em php, não estou conseguindo... ai vai o codigoArquivo tpl<!-- Dados do Formulario -->{$msgDisplay}{if $sysControl == "form"} <form enctype="multipart/form-data" name="formulario" id="formulario" method="post" onSubmit="return false;"> <input type="hidden" name="action" value="{$action}" > <!--<input type="hidden" name="arquivo" value="{$arquivo}">--> <table border="0" cellpadding="0" cellspacing="0" class="tableForm"> <tr> <td class="tdLabel"><label class="head">Arquivo:</label></td> <td class="tdValue"><input name="arquivo" type="file" value="{$arquivo}" id="arquivo" <!--maxlength="2097164"--> />------Parametro (Arquivos: Office 2000-2003-2007-txt-pdf-xls-htm-html) <button name="Submit" type="submit" class="btnMenu" name="Submit" value="Submit" > <img src="include/img/action_accept.gif" hspace="5" border="0" align="absmiddle" ><u>S</u>alvar</button></td> <!-- <div align="right"><button name="Submit" type="submit" class="btnMenu" name="Submit" value="Submit" ><img src="include/img/action_accept.gif" hspace="5" border="0" align="absmiddle" ><u>S</u>alvar</button></div></td>--> <!--<td class="tdValue"><input type="submit" class="btnMenu" name="Submit" value="Submit" />--> </td> </tr> </table> {/if}Não consigo passar o arquivo selecionado para upload como parametro para a minha classe, segue o metodo responsavel pelo upload://Copiando o arquivo public function copiar() { //$arquivo = $_REQUEST["arquivo"]; //$this->setDestino( $this->getSys()->getVar("destino") ); $this->setArq( $this->getSys()->getVar("arquivo") ); //$this->setArq($_REQUEST["arquivo"]); //echo $this->getSys()->getVar("arquivo"); //echo "------------>"; //echo $this->getDestino(); //echo $this->getArq(); //echo "----------->"; //print_r($_FILES); // Verifica se tem arquivo enviado $this->setFtemp($_FILES["arquivo"]["tmp_name"]);------------------- Aqui que não consigo passar o parametro $this->setFname($_FILES["arquivo"]["name"]); $this->setFsize($_FILES["arquivo"]["size"]); $this->setFtype($_FILES["arquivo"]["type"]); $this->setDestino($_SERVER['DOCUMENT_ROOT'] . "/admin/arquivos/"); echo $this->getFtemp() . "<br>"; //echo $this->getDest() . "<br>"; echo $this->getFname() . "<br>"; if ($this->getFsize() > 0 && strlen($this->getFname()) > 1) { // Verifica se é um arquivo valido if (preg_match('/^(.*)\.(doc|ppt|mdb|txt|pdf|xls|htm|html|xlsx|docx|pptx|accdb)$/', $this->getFname())) { if (!move_uploaded_file($this->getFtemp(), $this->getDestino() . $this->getFname())) { echo "Problemas no envio do Arquivo !!!" . $this->getDestino() . $this->getFname(); echo $this->getFtemp() . "<br>"; echo $this->getDest() . "<br>"; echo $this->getFname() . "<br>"; } else { echo "Upload do Arquivo efetuado com sucesso !!!"; echo $this->getFtemp() . "<br>"; echo $this->getDest() . "<br>"; echo $this->getFname() . "<br>"; //$this->getSys()->getTemplate()->assign("msgDisplay", $this->getSys()->printError()); //return $this->getSys()->getTemplate()->fetch("cad_artigos.tpl"); $this->getSys()->setErrorMessage(1); return $this->getForm("save", true); } } else { echo "Arquivo não Suportado !!!"; echo $this->getFtemp() . "<br>"; echo $this->getDest() . "<br>"; echo $this->getFname() . "<br>"; } } else { echo "Não foi selecionado arquivo para Envio!!!"; //echo $this->getDestino(); } }Conto com a ajuda de vocês.Obrigado. Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
Dotani
Pessoal Tudo bem...
Estou com problema na passagem de parametros entre minha classe e um arquivo tpl, gerado pelo Smarty, estou iniciando em php, não estou conseguindo... ai vai o codigo
Arquivo tpl
<!-- Dados do Formulario -->
{$msgDisplay}
{if $sysControl == "form"}
<form enctype="multipart/form-data" name="formulario" id="formulario" method="post" onSubmit="return false;">
<input type="hidden" name="action" value="{$action}" >
<!--<input type="hidden" name="arquivo" value="{$arquivo}">-->
<table border="0" cellpadding="0" cellspacing="0" class="tableForm">
<tr>
<td class="tdLabel"><label class="head">Arquivo:</label></td>
<td class="tdValue"><input name="arquivo" type="file" value="{$arquivo}" id="arquivo" <!--maxlength="2097164"--> />------Parametro
(Arquivos: Office 2000-2003-2007-txt-pdf-xls-htm-html)
<button name="Submit" type="submit" class="btnMenu" name="Submit" value="Submit" > <img src="include/img/action_accept.gif" hspace="5" border="0" align="absmiddle" ><u>S</u>alvar</button></td>
<!-- <div align="right"><button name="Submit" type="submit" class="btnMenu" name="Submit" value="Submit" ><img src="include/img/action_accept.gif" hspace="5" border="0" align="absmiddle" ><u>S</u>alvar</button></div></td>-->
<!--<td class="tdValue"><input type="submit" class="btnMenu" name="Submit" value="Submit" />-->
</td>
</tr>
</table>
{/if}
Não consigo passar o arquivo selecionado para upload como parametro para a minha classe, segue o metodo responsavel pelo upload:
//Copiando o arquivo
public function copiar() {
//$arquivo = $_REQUEST["arquivo"];
//$this->setDestino( $this->getSys()->getVar("destino") );
$this->setArq( $this->getSys()->getVar("arquivo") );
//$this->setArq($_REQUEST["arquivo"]);
//echo $this->getSys()->getVar("arquivo");
//echo "------------>";
//echo $this->getDestino();
//echo $this->getArq();
//echo "----------->";
//print_r($_FILES);
// Verifica se tem arquivo enviado
$this->setFtemp($_FILES["arquivo"]["tmp_name"]);------------------- Aqui que não consigo passar o parametro
$this->setFname($_FILES["arquivo"]["name"]);
$this->setFsize($_FILES["arquivo"]["size"]);
$this->setFtype($_FILES["arquivo"]["type"]);
$this->setDestino($_SERVER['DOCUMENT_ROOT'] . "/admin/arquivos/");
echo $this->getFtemp() . "<br>";
//echo $this->getDest() . "<br>";
echo $this->getFname() . "<br>";
if ($this->getFsize() > 0 && strlen($this->getFname()) > 1) {
// Verifica se é um arquivo valido
if (preg_match('/^(.*)\.(doc|ppt|mdb|txt|pdf|xls|htm|html|xlsx|docx|pptx|accdb)$/', $this->getFname())) {
if (!move_uploaded_file($this->getFtemp(), $this->getDestino() . $this->getFname())) {
echo "Problemas no envio do Arquivo !!!" . $this->getDestino() . $this->getFname();
echo $this->getFtemp() . "<br>";
echo $this->getDest() . "<br>";
echo $this->getFname() . "<br>";
} else {
echo "Upload do Arquivo efetuado com sucesso !!!";
echo $this->getFtemp() . "<br>";
echo $this->getDest() . "<br>";
echo $this->getFname() . "<br>";
//$this->getSys()->getTemplate()->assign("msgDisplay", $this->getSys()->printError());
//return $this->getSys()->getTemplate()->fetch("cad_artigos.tpl");
$this->getSys()->setErrorMessage(1);
return $this->getForm("save", true);
}
} else {
echo "Arquivo não Suportado !!!";
echo $this->getFtemp() . "<br>";
echo $this->getDest() . "<br>";
echo $this->getFname() . "<br>";
}
} else {
echo "Não foi selecionado arquivo para Envio!!!";
//echo $this->getDestino();
}
}
Conto com a ajuda de vocês.
Obrigado.
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.