File_get_content在本地服务器上运行,但不在服务器上托管

时间:2014-04-08 14:49:52

标签: php download codeigniter-2 file-get-contents codeigniter-url

我正在使用代码点火器的下载功能,因为我是框架的新手

我遇到了这个功能的问题,这个功能在localhost上正常工作但无法在服务器上运行..

描述我的问题

以下是我的控制器中的下载功能

    public function download()
 {
 $uri=$this->uri->segment(2);
 $check=array();
 $check['q_id']=$uri;
 $img=  $this->prototype_model->get_data($check,'orders');//getting data from db
 $imgname=$img['stl_image'];//stores the image name from result array
 $data = file_get_contents(base_url()."assets/upload_img/".$imgname);// Read the file's contents
 $name = $imgname;//name to download file
   force_download($name, $data);           
  }

当我搜索SO寻求解决方案时,我发现 allow_url_fopen = on ,我在我的服务器上检查了这一点,没关系。

我能够根据uri段获取数据,但file_get_content没有获取图像名称,服务器返回一些错误,如下所示

错误1

     Severity: Notice
     Message:  file_get_contents() [function.file-get-contents]: send of 30 bytes failed with errno=104 Connection reset by peer
     Filename: controllers/prototype.php
     Line Number: 796

错误-2

     Severity: Notice
     Message:  file_get_contents() [function.file-get-contents]: send of 2 bytes failed with errno=32 Broken pipe
     Filename: controllers/prototype.php
     Line Number: 796

任何建议都将不胜感激

0 个答案:

没有答案