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.

1
  • Have you checked the post_max_size? This has to exceed the max file size Commented Nov 8, 2013 at 14:37

5 Answers 5

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">
Sign up to request clarification or add additional context in comments.

1 Comment

Hi. Just added it, still NULL. Updated the initial post for my current form
1

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

var_dump ( $_FILES['file'] );

You are missing off the '

1 Comment

Please just edit your existing answer instead of adding new ones.
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

Comments

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?

1 Comment

Drat! someone beat me to answering :)
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 />';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.