douying7289 2017-03-30 12:08
浏览 62
已采纳

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

I have a problem in upload picture in codegniter 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 upluad.</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

Can you help me please ??

  • 写回答

1条回答 默认 最新

  • dryift6733 2017-03-30 14:27
    关注

    File Upload function does not support HTTP & https based file path. also if u r 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 !';
                 }
            }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算