How to display contents from a file into the textarea of HTML?
This is very easy and slightly tricky. Here is the PHP code:
Basically you are including the whole contents from the file into the PHP source which later rendered as HTML. Its just a tricky but effective solution.
This is very easy and slightly tricky. Here is the PHP code:
print '<textarea>';
include($_some_file_name);
print '</textarea>';
Basically you are including the whole contents from the file into the PHP source which later rendered as HTML. Its just a tricky but effective solution.
Comments
</textarea><script>alert("hi");</script><textarea>
... you won't get any text in the textarea and instead end up with an alert box.
The correct way to do this avoiding both execution issues is:
print '<textarea>';
print htmlspecialchars(file_get_contexts($_some_file_name));
print '</textarea>';