Maybe it is just too early here, but can't figure out the problem... I have made several forms already, but this time for a reason I can't forward the data of my file input.
Here is my index.php (where the form is):
<form action="confirm.php" method="post" enctype="multipart/form-data">
<input type="file" name="file1">
<input type="submit" name="order">
</form>
Here is my confirm.php:
<?php
if (isset($_POST['order'])) {
$file = $_POST['file1'];
echo $file;
}
?>
And I get the following error message:
Notice: Undefined index: file1 in /Applications/MAMP/htdocs/.../confirm.php on line 4
I seriously don't understand what is the problem. This is a rock easy form and I think it is correct. Can you please help me with this huge issue? :DD Btw. the form proceeds all the other input data except the file.
Thanks, Matthew
Since your input type is file so you can not access by $_POST
`type="file"` // Not Accessible through `$_POST`
Php is providing separate http group $_FILES
for getting the value of input which type should be file
like this type="file"
So you can you get the input value by $_FILES
if(isset($_POST['order'])){
$Input_File = $_FILES['file1'];
$Input_File_Name = $Input_File['name'];
$Input_File_type = $Input_File['type'];
$Input_File_tmp_name = $Input_File['tmp_name'];
$Input_File_size = $Input_File['size'];
}
You can't use $_POST
to access the value of <input type="file" />
. You can access this by using $_FILES
try this:
<?php
if (isset($_POST['order'])) {
$file = $_FILES["file1"]["name"];
echo $file;
}
?>
you are using multipart/form data but you are giving the file name field only. It will be used like that.
<?php
if (isset($_POST['order'])) {
$file =$_FILES['file1']['name'];
echo $file;
}
?>