jquery - Download file by form PHP -
I am trying to download JSN data via PHP. The file is being downloaded, but the DSN name does not get what I define, even in the file, prints only two letters from my JSN data.
The file appears inside:
[{
When JSON data is visible:
[{"SIZE": [16,16]}]
that is code:
var data est text = JSON.stringify (data); Var filename = $ ("# menu-save-text") Val (); Var _content = DataAsText; Jquery ('& lt; form action = "download.php" method = "post" & gt; Input gt; & lt; / form & gt; '). Attachment (' body '). Submit (). < / Code>
PHP:
& lt;? $ File name = $ post ["file name"]; header ("content-type: text / plain Header ("Pasteum: 0"); Header ("Cache-Control: Header (" Pasteum: Public "); Header (" Cache-Control:Required-modified, post check = 0, pre-check = 0 "); header (" cache-control: private ", incorrect); echo $ _POST [" content "];? & Gt;
The name of downloaded files is download.php
You suffer from an HTML injection vulnerability In JSON, "
is breaking your HTML:
The HTML you create looks like this:
[. Snip ..] & Lt; Input type = "hidden" name = "content" value = "[{" size ": [16,16]}]" />[...nnip ..]
How it will be parsed by the browser:
Input: value = "[}" // Size of proper character ": [16, etc ... // Unknown / Invalid HTML attribute < In other words, you have to quote your JSON for use in the HTML form attribute, e.g., from all the "
to and. Quot; Change
or create HTML using the appropriate domain methods, and set the value of content input through $ (...). .val (json_goes_here)
with jquery-type operation.
Comments
Post a Comment