-2
If I give an echo the contents of the file appear perfectly, but if I try to run this code the content even being there (echo shows) does not appear in the textarea.
$conteudo = file_get_contents("$arquivo");
$conteudo=trim($conteudo);
echo("$conteudo"); //aparece normalmente
//$conteudo = "Eu apareço"; //se eu tirar o comentário vai aparecer o texto
echo("<script>
window.parent.document.getElementById(\"id_textarea\").value=\"$conteudo\";
</script>");
No, this textarea is created in index, it finds the element normally because as commented above, if I switch to a string it normally puts in the textarea. Thank you.
– Luis Miguel
Got it. What’s in this
file_get_contents("$arquivo")
? HTML codes?– Sam
actually anything, I can put text that doesn’t work, I can put tags, in fact the business is so sinister that if I put in the text the test string it doesn’t show, but if I put $content="test" after it took the content of the text it shows.
– Luis Miguel
The problem is that if you have a line break in the content will give error in JS.
– Sam
True, now that I’ve seen that if you have line breaks you won’t, even if you’re in Aff quotes, you have a way to solve?
– Luis Miguel
Try it like this:
$conteudo=addslashes(trim(preg_replace("/\r\n/", "", $conteudo)));
– Sam
It was not, the console shows the same Uncaught Syntaxerror error: Invalid or Unexpected token
– Luis Miguel