0
안녕하세요, 저는 json 파일을 강제로 작성하는 함수를 작성했지만 버퍼가 파일을 연결하는 것처럼 보입니다. 일반적으로 그냥 JSON 개체이어야하지만 페이지 자체가 파일에 삽입되는 것처럼 보입니까?PHP 출력 버퍼가 이미 보내지는 파일을 만드시겠습니까?
[{"key":"16","role":null,"region":"Great White North","inspection_type":"citrus","inspection_number":"996","customer_number":"206-420-9564","report_date":"2012-10-21","status":"1","order_date":"2012-02-23 15:24:34","customer":"Jd Daniel","customer_division":"Field worker","memo":null,"billing_key":null,"report_key":"996","shipper":"Hanjin","po":"33215","location":"Boulder, CO","inspector":"Newman","commodity":"Apples","count":"32","size":"medium","label":"Granny Smith","variety":"Golden","pack_date":"0000-00-00","grower_lot":"Lots to grow","color1":"4","color2":"15","texture1":"","texture2":"","puff1":"","puff2":"","scar1":"","scar2":"","solidity1":"","solidity2":"","green1":"","green2":"","sugar_brix1":"","sugar_brix2":"","rating":"0","comments":"Comments 1"},{"key":"17","role":null,"region":"Great White North","inspection_type":"citrus","inspection_number":"996","customer_number":"206-420-9564","report_date":"2012-10-21","status":"0","order_date":"2012-02-23 15:24:34","customer":"Jd Daniel","customer_division":"Field worker","memo":null,"billing_key":null,"report_key":"996","shipper":"Jiun Ming","po":"4215","location":"South Holywood","inspector":"Gadget","commodity":"Grapes","count":"29","size":"46","label":"sweet","variety":"green","pack_date":"0000-00-00","grower_lot":"","color1":"","color2":"","texture1":"","texture2":"","puff1":"","puff2":"","scar1":"","scar2":"","solidity1":"","solidity2":"","green1":"","green2":"","sugar_brix1":"","sugar_brix2":"","rating":"0","comments":"Comments 2"}]
<!DOCTYPE html>
<html lang="en-US">
<head>
<title> </title>
<script src='http://www.google.com/jsapi'></script>
<script> google.load('jquery', '1.7.1'); </script>
<style type="text/css">
body {font-family: arial;}
p, ul {width:100%; text-align:left;font-size:80%;}
.reports_box {width:auto; padding:25px 20px 20px 20px;border:1px solid #91bce6;background-color:#eff5fb;}
input {width:121px; font-size:15px;padding:5px;}
.check input {padding:0 !important;}
.caps {text-transform:capitalize;}
이상한 권리? 이 버퍼를 제거하기 위해 버퍼를 플러시 할 수 없으며이 버퍼를 제거하는 더 좋은 방법이 필요합니다. 내 기능은 다음과 같습니다.
function getReportDown($array) {
unset($array['select']);
$cleanArray = filter_var_array($array ,FILTER_SANITIZE_STRING);
$array=array(); // needs to be secured -jd
foreach($cleanArray as $k=>$v) {
if(strpos($k,'find_') === false) {
$array[] = explode(':',$k); }
}
require('perms.php.inc');
require('dbconnect.class.inc');
$dbc = Database::obtain(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$dbc->connect();
$form=array();
foreach($array as $key=>$val) {
$form[] = array_pop($dbc->fetch_array("SELECT * FROM reports JOIN (SELECT * FROM `{$val[0]}` WHERE `key` = {$val[1]}) fruits ON inspection_number = fruits.report_key ORDER BY report_date DESC"));
}
$dbc->close();
$rand = randomAlphaNum(10).'.json';
header("Content-type: application/json");
header("Content-disposition: attachment; filename=$rand");
header('Content-Transfer-Encoding: binary');
echo json_encode($form);
//unlink($rand);
}