-1

I have file input in php

<form action="" method="POST" enctype="multipart/form-data">
  <input type="file" name="fileup">
</form>

the error was "Undefine Index". here is my code for php.

<?php
$file = strtolower($_FILES["uploadpic"]["name"]);
?>

the undefined index was uploadpic.

Ryan Vincent
  • 4,483
  • 7
  • 22
  • 31
Jimar Zape
  • 13
  • 1
  • 2
    Yeah - your input name is "fileup" not "uploadpic" – scrowler Apr 28 '15 at 03:22
  • possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – andrewsi Apr 28 '15 at 03:56

2 Answers2

5

Your element is named fileup and you're using ["uploadpic"]

  • Both of those must match.

Either you do $file = strtolower($_FILES["fileup"]["name"]);

or rename your element to:

<input type="file" name="uploadpic">
  • The choice is yours.

Reference links:

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
0

when calling or retrieving the post file data the name should be same as the name given in the file input field i.e. if your input name is fileup then you should retrieve data by $_FILES['fileup'] instead of using $_FILE[uploadpic]