简体   繁体   中英

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

I have a problem in upload picture in codeigniter this is my view:

<form method="post" action="<? echo site_url('do_upload'); ?>" id="createForm"  enctype="multipart/form-data" >
        <div style="display:none">
        <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash();?>" />
        </div> 

      <div class="form-group">
        <label for="exampleInputFile">Picture</label>
        <input type="file" name="picture" id="exampleInputFile">
        <p class="help-block">Choose file to upload.</p>
      </div>

    </div>
    <div class="modal-footer">
    <button type="submit" class="btn btn-primary">Save changes</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>

my controller:

public function do_upload()
{
    if(isset($_FILES['picture']))
    { 
         $dossier = base_url().'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 !';
         }
    }
}

and I have all time this problem:

Screen shot error

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 !';
         }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM