0

I have a simple form

<form method="post" action="editownpage.php" id="uploadForm" enctype="multipart/form-data">

    <label for="file">xxx</label>
    <input type="file" name="file" id="file"> <br>

    <label for="uplCss">xxx.</label>
    <textarea id="uplCss" name="uplCss"> <?php echo $css; ?></textarea> <br>

    <input type="submit" name="uplSubmit" id="uplSubmit" value="Hochladen">
</form>

The textarea field works like a charm, but I want to let the user upload a image. But when I do this var_dump($_FILES['file']); it is always null. No image can be processed ? What can be the reasons ? The max. file size in the php.ini is set to 3mb. The images I'm uploading are 70kb.

Musterknabe
  • 5,252
  • 12
  • 56
  • 113

5 Answers5

3

You're missing your enctype="multipart/form-data" attribute in your <form> tag. Without it the file will not upload.

<form enctype="multipart/form-data" method="post" action="editownpage.php" id="uploadForm">
John Conde
  • 212,985
  • 98
  • 444
  • 485
1

Also your var_dump ( $_FILES['file] ); should be:

var_dump ( $_FILES['file'] );

You are missing off the '

MarkP
  • 2,518
  • 5
  • 30
  • 48
1

You have

var_dump ( $_FILES['file] );

You are missing the closing quote.

Use $_FILES['file'];

Read this documentation about how to access the file properties. it can be helpful for you

PHP File Upload

Bill the Lizard
  • 386,424
  • 207
  • 554
  • 861
Danny22
  • 1,900
  • 3
  • 33
  • 62
0

You're missing your enctype="multipart/form-data" attribute in your form tag

See this example as to why it is important.

What does enctype='multipart/form-data' mean?

Community
  • 1
  • 1
MarkP
  • 2,518
  • 5
  • 30
  • 48
0

Try this without giving the index name. Its working at my side.

echo '<pre>';
var_dump($_FILES);
echo '</pre>';

or use.

echo $_FILES['file']['name'].'<br />';
echo $_FILES['file']['type'].'<br />';
echo $_FILES['file']['size'].'<br />';
Sid Ch
  • 21
  • 3