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.

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

报告相同问题?