Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

failed to open stream: HTTP wrapper does not support writeable connections

Tags:

php

caching

I have uploaded my localhost files to my website but it is showing me this error:-

: [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 

What i personally feel that the contents get saved in a file in cache folder and when i uploaded the files to my web server it is trying to access the cached localhost folder.

like image 484
Django Anonymous Avatar asked Mar 17 '12 07:03

Django Anonymous


2 Answers

Instead of doing file_put_contents(***WebSiteURL***...) you need to use the server path to /cache/lang/file.php (e.g. /home/content/site/folders/filename.php).

You cannot open a file over HTTP and expect it to be written. Instead you need to open it using the local path.

like image 62
drew010 Avatar answered Oct 12 '22 21:10

drew010


you could use fopen() function.

some example:

$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);     } 
like image 44
The Bumpaster Avatar answered Oct 12 '22 23:10

The Bumpaster