Add parameter to PHP
When I submitted the image to below code, uploadImage.php via POST method, how to add String parameter?
<?php
$hasError = false;
foreach( $_FILES as $i=>$file )
{
if ( $file['error'] )
{
$hasError = true;
}
}
if ( ! $hasError )
{
$myFilePath = '_uploads/'.'_'.$file["name"];
$dta = file_get_contents($file['tmp_name']);
file_put_contents($myFilePath, $dta);
}
else
{
echo('Stick custom error message here');
}
?>
+2
a source to share
1 answer
If you understand correctly, add the page where the form is submitted from:
<form ....>
...
<input type="text" name="my_key" value="default value" />
</form>
Then you can access it from $ _POST:
if (array_key_exists("my_key", $_POST) && !is_array($_POST["my_key"]))
echo htmlentities($_POST["my_key"]);
else
//error handling; field was not included or multiple values were given
+2
a source to share