0

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.

4
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by amindabj
Featured Replies
  • you have missed the quote at the end of the method="POST try this [CODE=php] <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']; } ?> [/CODE] … Read More

1

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

Edited by karthik_ppts: n/a

0

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?

0

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

0
<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?

0

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.

0

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'];
    }
    ?>

Edited by karthik_ppts: n/a

0

i am still getting the same error...

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

0

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

0

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

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

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.