skip to Main Content

I am gettting this error for moving file from my local machine to Cpanel Web Server.The Error is:- failed to open stream: HTTP wrapper does not support writeable connections

I am Tried this code:-

<?php
$flag=0;
$uploads_dir ="http://mysubdomain.in";

 foreach ($_FILES["pictures"]["error"] as $key => $error) {
 if ($error == UPLOAD_ERR_OK) {
    $tmp_name = $_FILES["pictures"]["tmp_name"][$key];

    $name = basename($_FILES["pictures"]["name"][$key]);
    echo $name;
    move_uploaded_file($tmp_name, "$uploads_dir/".$name);
   $flag=1;
    }
  else
$flag=0;
  }
if($flag==1)
echo 'uploaded successfully';
else
echo 'Failed to upload';
  ?>

Error on this line:-
move_uploaded_file($tmp_name, “$uploads_dir/”.$name);

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

2

Answers


  1. The best way to transfer images from localhost to a cPanel is to use FTP or SFTP using FileZilla or any FTP client.

    You can also use the builtin cPanel –> File Manager to upload images.

    Login or Signup to reply.
  2. Instead of doing file_put_contents(http url) you need to use the server path (e.g. /var/www/html/…).

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search