Linux / PHP / Java / Designer

As melhores dicas estão aqui.

PHP Script de Upload simples

| 1 Comentário

Um Script Simples em PHP para upload de único arquivo.

<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="119%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Arquivo para Upload  </strong></td>
</tr>
<tr>
<td>Selecione o arq.
<input name="ufile" type="file" id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
< ?php
//pasta de upload
$path= "upload/".$HTTP_POST_FILES['ufile']['name'];
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";

//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "Nome do arquivo :".$HTTP_POST_FILES['ufile']['name']."<br />";
echo "Tamanho do arquivo :".$HTTP_POST_FILES['ufile']['size']."<br />";
echo "Tipo de arquivo :".$HTTP_POST_FILES['ufile']['type']."<br />";
echo "<img src=\"$path\" width=\"150\" height=\"150\"/>";
}
else
{
echo "Erro";
}
}
?>

One Comment

  1. AFAICT you’ve covered all the bases with this anwser!

Deixe uma resposta

Campos requeridos estão marcados *.