我已经编写了关于图像上传的代码,但它在byexost服务器上不起作用.我在"uploads/products"服务器的根位置下创建了目录,该文件夹也是可写的,但它仍然无法正常工作.请帮忙.
我打开了应用程序的错误日志记录.如果我访问"application/logs"目录的日志文件,则显示错误.
错误 - 2018-03-25 00:47:08 - > 404找不到页面:/ index
错误 - 2018-03-25 00:58:24 - >上传路径似乎无效.
byexost服务器中图像上传目录的图片
我的产品控制器代码.
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());
}
}
Run Code Online (Sandbox Code Playgroud)
检查upload_tmp_dir权限(PHP 使用的用户权限)。本机文件上传分为两个步骤:上传到 tmp 目录并移动到您想要的任何位置。
另请确保您尝试上传的文件符合上传限制。
| 归档时间: |
|
| 查看次数: |
404 次 |
| 最近记录: |