How to upload a file and send the other form data in a single action?
I have (as an example) the following form:
<form method="POST" name="form" action="ccd.php">
<input value="" type="text" id="nome" name="nome"/>
<input value="" type="text" id="modelo" name="modelo"/>
<input type="file" id="foto" name="foto"/>
</form>
But when I add the enctype from "multipart / form-data" to pass the data from the file to ccd.php , it does not send < in and template .
<form enctype="multipart/form-data" method="POST" name="form">
When I remove the enctype from "multipart / form-data", it passes the name and template data, but file data.
$uploaddir = "../fotos";
if (isset($_POST['foto'])){
$uploadfile = $uploaddir . basename($_FILES['foto']['name']);
if(move_uploaded_file($_FILES['foto']['tmp_name'], $uploadfile){}
}
And I get the error:
Notice: Undefined index: foto in /media/[...]/ccd.php on line 31