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

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -