无法打开流:HTTP包装器不支持可写连接

Dja*_*ous 71 php caching

我已将我的localhost文件上传到我的网站,但它显示我这个错误: -

: [2] file_put_contents( ***WebsiteURL*** /cache/lang/ ***FileName*** .php) 
[function.file-put-contents]: failed to open stream: HTTP wrapper does 
not support writeable connections | LINE: 127 | FILE: /home/content/
***Folders\FileName*** .php
Run Code Online (Sandbox Code Playgroud)

我个人认为内容保存在缓存文件夹中的文件中,当我将文件上传到我的Web服务器时,它正在尝试访问缓存的localhost文件夹.

dre*_*010 148

而不是file_put_contents(***WebSiteURL***...)你需要使用服务器路径/cache/lang/file.php(例如/home/content/site/folders/filename.php).

您无法打开文件HTTP并期望它被写入.相反,您需要使用本地路径打开它.


The*_*ter 14

你可以使用fopen()函数.

一些例子:

$url = 'http://doman.com/path/to/file.mp4';
$destination_folder = $_SERVER['DOCUMENT_ROOT'].'/downloads/';


    $newfname = $destination_folder .'myfile.mp4'; //set your file ext

    $file = fopen ($url, "rb");

    if ($file) {
      $newf = fopen ($newfname, "a"); // to overwrite existing file

      if ($newf)
      while(!feof($file)) {
        fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );

      }
    }

    if ($file) {
      fclose($file);
    }

    if ($newf) {
      fclose($newf);
    }
Run Code Online (Sandbox Code Playgroud)