【发布时间】:2018-03-25 06:04:57
【问题描述】:
我已经编写了图片上传的代码,但它在 byethost 服务器中不起作用。我在服务器的根目录下创建了"uploads/products" 目录,该文件夹也是可写的,但仍然无法正常工作。请帮忙。
我为应用程序打开了错误日志记录。如果我访问"application/logs" 目录的日志文件,则会显示以下错误。
错误 - 2018-03-25 00:47:08 --> 404 页面未找到:/index
ERROR - 2018-03-25 00:58:24 --> 上传路径似乎不是 有效。
bytehost服务器中图片上传目录的图片
我的产品控制器的代码。
if(isset($_FILES['productimage']['name'])){
$filename = $_FILES['productimage']['name'];
$config['file_name'] = $filename;
$config['upload_path'] = realpath(FCPATH.'uploads/products/');
$config['allowed_types'] = 'jpg|jpeg|png';
$config['remove_spaces'] = TRUE;
$config['encrypt_name'] = TRUE;
$config['min_width'] = 360;
$config['min_height'] = 360;
$config['max_width'] = 360;
$config['max_height'] = 360;
$this->upload->initialize($config);
if($this->upload->do_upload('productimage')){
$uploadeddata = $this->upload->data();
$data['image'] = $uploadeddata['file_name'];
}else{
$this->session->set_flashdata('error', $this->upload->display_errors());
$result = array("status"=>false, "message"=>$this->upload->display_errors());
}
}
【问题讨论】:
-
试试 $config['upload_path'] = 'application/uploads/products/';
-
$config['upload_path'] 的值显示为“/home/vol15_4/byethost14.com/b14_21532169/htdocs/uploads/products”
-
当我尝试 $config['upload_path'] = 'application/uploads/products/' 时,日志生成错误“无法将文件写入磁盘。”
-
您的托管计划可能磁盘空间不足
标签: php codeigniter-3