0
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 the ccd.php, it does not send the data of name and model.
<form enctype="multipart/form-data" method="POST" name="form">
When I remove the enctype of "Multipart/form-data", it passes the data of name and model, but does not pass the 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 mistake:
Notice: Undefined index: foto in /media/[...]/ccd.php on line 31
something that is in the question does not match the reality has to use the
enctype
,But, you look at question, What do you say you don’t carry? What is line 31? missing supplement your question !!!– novic