douyi3833 2016-06-30 10:18
浏览 24

指定变量时fopen不工作

im trying to get the contents of file and storing it in a file on my system, that function is working fine, when i specify the url the function is working fine, but when supply a variable which has url stored in it, it stores an empty file, meaning it failed getting the contents of the file, i have tried dozens of solutions but none is working, there is also a solution on php.net but its also not working, here is the code:

 $filePath = str_replace("Vary:", "", $items[13]);
//$encoding = mb_detect_encoding($filePath);
//$filePath = mb_convert_encoding($filePath, "ASCII", $encoding);
//$filePath = str_replace("?", "", $filePath);
//$filePath = addslashes($filePath);
//file_put_contents('path/'.$file_name, fopen("".$target_url."","r"));
file_put_contents('path/'.$file_name, fopen($filePath,"rb"));
  • 写回答

1条回答 默认 最新

  • dongzhuo3376 2016-06-30 10:36
    关注

    Figured it out just trimmed the variable and it worked

    $filePath = str_replace("Vary:", "", $items[13]);
    $filePath = trim($filePath);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大