[英]Php inserting escape characters in the csv output file
I am using this php code to allow the user to send dojo.enchancedgrid to file and download it to his machine. 我正在使用此php代码允许用户将dojo.enchancedgrid发送到文件并将其下载到他的计算机。 The procedure works fine, but the output csv file has the escape lines for the quotes.
该过程工作正常,但是输出的csv文件包含引号的转义行。 How can I avoid php inserting those for me.
我如何避免php为我插入那些。 The string that is passed to the function(str) is ok, but after passes through the php code is different.
传递给function(str)的字符串是可以的,但是经过php代码传递的字符串不同。
My javascript code: 我的JavaScript代码:
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);
});
} }
My php code: 我的PHP代码:
$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;
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:
以下是输出的csv文件:
Lon,Lat,Network,RouteId,Measure Lon,Lat,Network,RouteId,Measure
-74.18143812,40.62733114,\\"Named Route\\",IN278,1 -74.18143812,40.62733114,\\“命名的路线\\”,IN278,1
-73.90131905,40.75932358,\\"Named Route\\",IN278,25 -73.90131905,40.75932358,\\“命名的路线\\”,IN278,25
-73.8005193,40.73819062,\\"Named Route\\",IN495,10 -73.8005193,40.73819062,\\“命名路线”,IN495,10
-73.82437443,40.79381815,\\"Named Route\\",IN678,12 -73.82437443,40.79381815,\\“命名的路线\\”,IN678,12
-73.79087796,40.66589334,\\"Named Route\\",\\"NY 27\\",12 -73.79087796,40.66589334,\\“命名的路线\\”,\\“ NY 27 \\”,12
<-- Hosting24 Analytics Code --> <-Hosting24 Analytics代码->
<--End Of Analytics Code --> <-分析代码结尾->
As zerkms suggested, this is likely due to magic quotes
. 就像塞克姆斯建议的那样,这可能是由于
magic quotes
。
Try disabling them. 尝试禁用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.