I tried running this code

<form action = "upload.php" method="POST enctype="multipart/form-data">
<input type="file" name="file"><BR><BR>
<input type="submit" name = "Submit" value ="Submit">
</form>


<?php
echo $name = $_FILES;
$size = $_FILES;
$type = $_FILES;
$tmp_name = $_FILES;

?>

but im having these errors
Notice: Undefined index: file in C:\xampp\htdocs\series\fileupload\upload.php on line 2

Notice: Undefined index: file in C:\xampp\htdocs\series\fileupload\upload.php on line 3

Notice: Undefined index: file in C:\xampp\htdocs\series\fileupload\upload.php on line 4

Notice: Undefined index: file in C:\xampp\htdocs\series\fileupload\upload.php on line 5


do you knwo whats the problem here?
I was told to use isset but im not really sure of how to code it.

you have missed the quote at the end of the method="POST
try this

<form action = "upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"><BR><BR>
<input type="submit" name = "Submit" value ="Submit">
</form>


<?php
if($_POST["submit"])
{
echo $name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
}
?>

Use [/B] tags to post your code[code=php] tags to post your code

thanks for the reply karthik
but it doesnt work

i get this reply
Notice: Undefined index: submit in C:\xampp\htdocs\series\fileupload\upload.php on line 8

Do you know what might be the problem?

post your recent code with [/B] tags. It'll help to identify the problem[code=php] tags. It'll help to identify the problem

<form action = "upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"><BR><BR>
<input type="submit" name = "Submit" value ="Submit">
</form>


<?php
	if($_POST["submit"])
	{
		echo $name = $_FILES['file']['name'];
		$size = $_FILES['file']['size'];
		$type = $_FILES['file']['type'];
		$tmp_name = $_FILES['file']['tmp_name'];
	}
?>

like this?

The reply i saw in youtube from someone who has the same problem
The code does not work with PHP 5.3.0 ... you need to wrap all variables with an if(isset(..)) { do..something } so they don't run on a first page load.

but i still dont get it.

in line 8 Put capital S for your submit as follows

<form action = "upload.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="file"><BR><BR>
    <input type="submit" name = "Submit" value ="Submit">
    </form>
     
     
    <?php
	if($_POST["Submit"])
    {
    echo $name = $_FILES['file']['name'];
    $size = $_FILES['file']['size'];
    $type = $_FILES['file']['type'];
    $tmp_name = $_FILES['file']['tmp_name'];
    }
    ?>

i am still getting the same error...

Notice: Undefined index: Submit in C:\xampp\htdocs\series\fileupload\upload.php on line 9

oh got it. It should be $_POST
single quotation

Mark this thread as solved if your problem solved

in html data the variable of submit button is "Submit"

in php code

if($_POST["submit"])

THE ERROR IS variable name changed this means capital letter changed Submit to submit

and use single quote on $_POST

Have an '@' in front, and that should solve ur issue.

@$name = $_FILES['file']['name'];

echo = @$name = $_FILES['file']['name'];

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.