Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp inserting escape characters in the csv output file
    primarykey
    data
    text
    <p>I am using this php code to allow the user to send dojo.enchancedgrid to file and download it to his machine. The procedure works fine, but the output csv file has the escape lines for the quotes. How can I avoid php inserting those for me. The string that is passed to the function(str) is ok, but after passes through the php code is different.</p> <p>My javascript code:</p> <pre><code>function exportCsv(){ var g = dijit.byId("grid"); g.exportGrid("csv",{ writerArgs: { separator: "," } }, function(str){ alert(str); var form = document.createElement('form'); dojo.attr(form, 'method', 'POST'); document.body.appendChild(form); dojo.io.iframe.send({ url: "csv.php", form: form, method: "POST", content: {exp: str}, timeout: 15000 }); document.body.removeChild(form); }); </code></pre> <p>}</p> <p>My php code:</p> <pre><code>$time = time(); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=\"grid_$time.csv\""); $exportedData = $_POST['exp']; echo $exportedData; </code></pre> <p>Also the server is inserting some analytics code in the rows as well… Thank you very much for the help guys. Below is the output csv file:</p> <p>Lon,Lat,Network,RouteId,Measure</p> <p>-74.18143812,40.62733114,\"Named Route\",IN278,1</p> <p>-73.90131905,40.75932358,\"Named Route\",IN278,25</p> <p>-73.8005193,40.73819062,\"Named Route\",IN495,10</p> <p>-73.82437443,40.79381815,\"Named Route\",IN678,12</p> <p>-73.79087796,40.66589334,\"Named Route\",\"NY 27\",12 </p> <p>&lt;-- Hosting24 Analytics Code --></p> <p>&lt;--End Of Analytics Code --></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload