Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » PHP reading of a file sent via a form(I made the decision to write a super-simple php script that simply reads the form and emits one if it isn't submitted. However, if the form is submitted, I want my script to retrieve the data from the)
PHP reading of a file sent via a form [message #1859936] Thu, 06 July 2023 08:27
Manikanta Choudary is currently offline Manikanta ChoudaryFriend
Messages: 2
Registered: April 2023
Junior Member
Here's what I got for now:

<?php

echo "<div class='form-container'>";

if (isset($_POST['json'])){

$json = file_get_contents('php://input');
$json_data = json_decode($json,true);

// Display data
echo "post json: " . $_POST['json'] . "<br />";
echo "json: " . $json . "<br />";
echo "json data: " . $json_data . "<br />";
print_r($json_data);
} else {
echo "<form action='' method='post'>";
echo "<input type='file' id='json' name='json'>";
echo "<input type='submit'>";
echo "</form>";
}

echo "</div>";

?>
I made numerous attempts to obtain the provided data:
$json = file_get_contents($_FILES['json']['tmp_name']);
$json = file_get_contents($_POST['json']);

But nothing seems to function, and it appears that the file is always empty? When echoing $json, only the filename and no content are printed:
post json: 2022_7_30_12_24_PRACTICE.json
json: json=2022_7_30_12_24_PRACTICE.json
json data:
How do I download this file?
Previous Topic:Support for PHP 8
Next Topic:Eclipse IDE for PHP Developers
Goto Forum:
  


Current Time: Thu May 02 03:25:38 GMT 2024

Powered by FUDForum. Page generated in 0.02916 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top