2018-10-28 20:37
浏览 588


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!

图片转代码服务由CSDN问答提供 功能建议


所以我 我正在从网址下载文件并尝试将其保存到这样的文件夹中:

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

当我运行时,我收到此错误: message: “file_put_contents(../ uploads / 20181028203041.mp3):无法打开流:没有这样的文件或目录”

当我运行此行时: \ n

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

该文件很好地插入我的公共文件夹。 我有一个上传文件夹,但这不起作用。 我在这里犯了什么愚蠢的错误。


请 帮助!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    点赞 打赏 评论

相关推荐 更多相似问题