douaoli5328 2013-07-26 05:17
浏览 24
已采纳

为什么在上传xml文件PHP后更改数据

i have the code to upload xml file using dom.

if (!$dom->load($folderName . "/" . $fvalue)) {

echo "<br>".$fvalue." file is corrupt or Tags are not closed properly  ";

}

it uploads the file BUT after uploading, there are 3 whitespaces in the start of the file before any xml Tag. Problem is we download uploaded file and upload again. but with whitespaces in the start of the file, dom dont allow to upload the file as it is corrupted.(i check the validation of xml using xmlvalidation.com) which returns error because there are spaces at the start. if i remove space manually than no error.

How i can upload the file without adding spaces at the start ?
I checked to remove spaces from file etc. but i dont want to do that. i want to upload the file without changing.

  • 写回答

1条回答 默认 最新

  • dtwbp26022 2013-07-26 07:55
    关注

    problem was with downloading the file. after download there was some spaces in the start of the file. code was

    header("Content-type: application/force-download; charset=utf-8");
    header("Content-type: application/force-download");
    header("Content-disposition: attachment;filename=" . $downFileName);
    readfile($filename);
    

    i changed to this and it's working fine now.

    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($downFileName));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($filename));
    ob_clean();
    flush();
    readfile($filename);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境