0
我創建了文本文件並在執行代碼時下載。但我需要將此下載的文件存儲在服務器內的指定文件夾中。我嘗試過很多方法,但我沒有得到任何解決方案。我在下面提到了我的代碼,任何人都可以引導我嗎?在php中創建內容類型並下載指定的路徑?
$saving_name = $i.''.$machineid.'.'.$count_pad;
foreach($data['SalesDetails'] as $d)
{
$val = $d->inv_total - $d->inv_discount;
$explodedval = explode(".",$val);
$totalval = str_pad($explodedval['0'], 8, "0", STR_PAD_LEFT);
$totalvals = str_pad($explodedval['1'], 2, "0", STR_PAD_RIGHT);
$result = $totalval.'.'.$totalvals;
$dates = str_replace("-","",$d->date);
$out .= $i.''.$machineid.''.$dates.''.$result.' '."\r\n";
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$saving_name.'.txt');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo "\xEF\xBB\xBF"; // UTF-8 BOM
echo $out;
exit;
這裏的路徑需要移動的下載文件,/var/www/html/art/assets/uploads/edi/sample.txt
我在本地系統下載的代碼。但我需要在服務器文件夾內下載。如何移動或如何將路徑設置到指定的文件夾中。 –