我在将 CSV 文件直接下载到我的浏览器而不将文件存储在我的服务器上的某个位置时遇到了问题。我找到了一个教程(https://www.perpetual-beta.org/weblog/php-stream-file-direct.html),但我似乎无法让它工作!
这是我的主要功能:
public function exportRecord($id) {
$contest = (string) $this->getContest($id);
$entries = (array) $this->getEntries($id);
$filename = sprintf('%1$s-%2$s-%3$s', str_replace(' ', '', $contest['name']), date('Ymd'), date('His'));
$output = fopen('php://output', 'w');
ob_start();
$header = array(
'First Name',
'Last Name',
'Address',
'City',
'State',
'Zip',
'Phone',
'Email',
'Item Purchased',
'Partner Name',
'Partner #',
'Date Entered',
'Subscribe'
);
fputcsv($output, $header);
foreach ($entries as $entry) {
fputcsv($output, $entry);
}
$string = ob_get_clean();
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: …Run Code Online (Sandbox Code Playgroud) 有没有人有将.NET / Angular项目发布到Netlify的经验?我正在使用Angular Microsoft.AspNetCore.SpaTemplates模板。在Netlify上,我得到了一个非零的退出代码,这使我无法发布。这是我的输出:
9:44:44 AM: Build ready to start
9:44:44 AM: Fetching cached dependencies
9:44:44 AM: Starting to download cache of 8.9MB
9:44:45 AM: Finished downloading cache in 225.765972ms
9:44:45 AM: Preparing Git Reference refs/heads/master
9:45:00 AM: Running build command: dotnet restore && dotnet build && dotnet run
9:45:02 AM: Downloading and installing node v6.11.4...
9:45:02 AM: Downloading https://nodejs.org/dist/v6.11.4/node-v6.11.4-linux-x64.tar.xz...
9:45:03 AM:
9:45:03 AM: 0.0%
9:45:03 AM:
1.1%
9:45:03 AM:
### 4.9%
9:45:03 AM:
##############
9:45:03 AM: 19.8%
9:45:03 AM: …Run Code Online (Sandbox Code Playgroud)