1

input file not work :

form.php

<form  action='process.php' method="post"  enctype="multipart/form-data" >
<input type='text' name='name' />
<input type='file' name='photo' />
<input type='submit' name='submit' />
</form>

process.php

if($_POST){


foreach($_POST as $key = > $value ){
   if($key!='submit')
    echo $key.'='.$value.'<br/>';
}


}

output:

name=name


?! who can solve this problem for input files. please helpppppp....

Daniel
  • 11
  • 2
  • 6
  • As a note, adding extra Ps onto 'help' doesn't make your question that more urgent/important/etc. Secondly, you do realize that file inputs are arrays themselves, right? – Daedalus Dec 12 '13 at 23:58
  • I don't speak/read whatever that is. Please try to communicate in english. – Daedalus Dec 13 '13 at 00:16
  • Thank you, The above code does not work for input files How I fixed form data without the need to write their name into the form I send them all like this, output should be : key=name /r/n key=photo – Daniel Dec 13 '13 at 00:28

3 Answers3

1
foreach($_POST as $keyPost => $valuePost){ echo '<br>'.$keyPost." => ".$valuePost; }
kampageddon
  • 1,409
  • 15
  • 13
0
$key = > $value

is not valid syntax.

$key => $value

PHP should have told Syntax error, unexpected '=' and on which line

Popnoodles
  • 28,090
  • 2
  • 45
  • 53
0

You need to use $_FILES instead of $_POST.

And since $_FILES will return an array you can't just echo $value; See: Print $_POST variable name along with value

Community
  • 1
  • 1
galengodis
  • 901
  • 1
  • 9
  • 18