3
EDIT: Even if you put the ENCTYPE tag in the form, the problem persists.
I’m trying to use the $_FILES
for the first time, and I’m having a hard time. It’s like he’s getting nothing. Look at the code I’m using.
HTML:
<form id="formtiles" method="post" enctype="multipart/form-data" action="scripts/cadastro.php" >
<label for="logo"><b>Logotipo: </b></label>
<input name="logo" type="file" id="logo" data-mini="true"/>
<input type="submit" form="formtiles" value="Gravar" id="enviadadoscliente" data-inline="true" data-icon="check"/>
</form>
PHP:
$location = 'public_html/teste/grid/img';
if (isset($_FILES['logo'])) {
$name = $_FILES['logo']['name'];
$tmp_name = $_FILES['logo']['tmp_name'];
$error = $_FILES['logo']['error'];
if ($error !== UPLOAD_ERR_OK) {
echo 'Erro ao fazer o upload:', $error;
} elseif (move_uploaded_file($tmp_name, $location . $name)) {
echo 'Uploaded';
}
}
Thanks in advance for the help.
For $_FILES to work, in principle, its form must contain: <form enctype= "Multipart/form-data">
– lys