failed to open stream: HTTP wrapper does not support writeable connections
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.
Codeigniter - failed to open stream: HTTP wrapper does not support writeable connections
File Upload function does not support HTTP & https based file path. also if you are used linux based os like ubuntu or mac to give the folder permission is 777 of all folder for ex. assets , image and product those three folder need read & write permission 777
public function do_upload()
{
if(isset($_FILES['picture']))
{
$dossier ='./assets/image/product/'; //based folder path if is inside public so u can use $dossier = './public/assets/image/product/';
$fichier = basename($_FILES['picture']['name']);
if(move_uploaded_file($_FILES['picture']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
}
}
}
Can't fix error failed to open stream: HTTP wrapper does not support writeable connections
Instead of doing
$target_dir = "http://myDomainName.com/SchoolStore/Images/";
you need to use the server path to
/SchoolStore/Images/
(e.g. /home/content/proj/SchoolStore/Images/
).
You cannot open a file via HTTP. Instead you need to open it using the local path.
Failed to open stream: HTTP wrapper does not support writeable
You are getting the error because you are trying to open a file over HTTP and expect it to be written on a local path. Remove "base_url()" and replace it with a local path.
As you are looking to store the file under the "public" directory, you can update the code to -
if ($file->isValid() && ! $file->hasMoved()) {
$rectocni = $file->getRandomName();
$file->move(ROOTPATH.'public', $rectocni);
}
"ROOTPATH" is a constant that has the path to the project root directory.
It is not good practice to store the uploaded file in the "public" directory, instead, look to place it under a sub directory under "writable".
Getting error with move_uploaded_file HTTP wrapper does not support writeable connections
Use this:
$uploadfile = $_SERVER['DOCUMENT_ROOT'] . '/sites/bestinfo/images/news/CodeCogsEqn.gif';
Related Topics
Differencebetween Sessions and Cookies in PHP
How to Place Two Forms on the Same Page
Directory Index Forbidden by Options Directive
String Contains Any Items in an Array (Case Insensitive)
Pass Extra Parameters to Usort Callback
Getting Complete Path of Uploaded File - PHP
Split Alphanumeric String Between Leading Digits and Trailing Letters
How to Destroy the Session Cookie Correctly with PHP
Autoloading Classes in PHPunit Using Composer and Autoload.Php
Which Mime Type Should I Use for Mp3
Display Message Before Redirect to Other Page
Php: Static and Non Static Functions and Objects