Jump to content

[SOLVED] Help with file input form tag


awrobinson

Recommended Posts

I'm brand new to PHP, working my way through "Learning PHP 5" by David Sklar. I am trying to web-ify a script that processes a log file. I need to input the filename of the log file. I am having trouble with the "file" input form tag.

 

Boiled down, this is the form spec I tried first:

 

<form action="fileform.php" method="POST">

<input type="file" name="logfile" size="30">

<input type="submit" name="submit" value="Submit">

<input type="hidden" name="_submit_check" value="1">

</form>

 

I am checking the output of the form with this boiled down php code:

 

<?php

print_r($_POST);

?>

 

The output I get is this:

 

Array ( [logfile] => elisa.log [submit] => Submit [_submit_check] => 1 )

 

I get the filename, but not the path. I did a bit of research, and it was apparent I needed the "enctype" option for the form tag:

 

<form action="fileform.php" method="POST" enctype="multipart/form-data">

 

However, when I run my test with this form tag, the results do not seem to even acknowledge the file input tag exists:

 

Array ( [submit] => Submit [_submit_check] => 1 )

 

So my question is simple. What don't I know?

 

Thanks!

 

Andrew Robinson

 

 

Link to comment
https://forums.phpfreaks.com/topic/113492-solved-help-with-file-input-form-tag/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.