dousi2013 2018-10-28 20:37
浏览 721
已采纳

即使文件夹存在,file_put_contents也无法打开流

This is really simple and yet I am really struggling.

So I am downloading a file from a url and trying to save it into a folder like this:

file_put_contents('../uploads/' . $newFilename, fopen('http:' . $process->output->url, 'r'));

When I run that I get this error: message: "file_put_contents(../uploads/20181028203041.mp3): failed to open stream: No such file or directory"

When I run this line:

file_put_contents($newFilename, fopen('http:' . $process->output->url, 'r'));

The file drops nicely into my public folder. I do have an uploads folder, but this just isn't working. What silly mistake have I made here.

Proof of the folder: enter image description here

Please help!

  • 写回答

1条回答 默认 最新

  • donglin6313 2018-10-28 21:03
    关注

    If you can successfully save to public in this way, than try to change '../uploads/' to uploads/. In case of ../uploads/ you are trying to save to beatpub/uploads folder.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试