Masoud Masoud - 1 month ago 17
PHP Question

difference between action="." and action=" "

Sorry if my question is basic. I have seen the code below on a tutorial for uploading a file. It uses

action ="."
, I know
action=" "
means page to itself but I do not know what means
action ="."
.

Another question is it uses:

<input type="hidden" name="action" value="upload">


I would like to know what does input
type="hidden"
and, is there relation between action attribute in form and value of name attribute in input.

<form id="upload_form" action="." method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="upload">
<input type="file" name="file1"><br>
<input id="upload_button" type="submit" value="Upload">

------------------------------------------------

switch ($action) {
case 'upload':
...}

Answer

There is no difference between action="." and action="". Either will redirect you to the current page.

The element having the attribute type="hidden" is simply a supplementary input element that is hidden, which can have a value to be passed when submitting the form.