Codeigniter文件上传不能在Live服务器上工作
问题描述:
我不能将图像上传到文件夹在线,但它在本地主机上完美工作。Codeigniter文件上传不能在Live服务器上工作
下面是我的代码
$this->load->helper(array('form', 'url'));
if (empty($_FILES['photo']['name'])) {
$image=$this->input->post('image');
} else {
$config = array(
'upload_path' => "uploads/",
'allowed_types' => "gif|jpg|png|jpeg",
);
$this->load->library('upload',$config);
if($this->upload->do_upload('photo')) {
$upload_data = $this->upload->data();
$image = $upload_data['file_name'];
} else {
$error = array('error' => $this->upload->display_errors());
redirect(base_url().'uploaderror');
}
}
请帮助寻找解决方案 感谢
家伙感谢您的帮助,问题是与服务器 PHP版本我固定它
答
也可能是试试这个代码由于PHP服务器版本和它的选项。
1).logging到您的cPanel账户
2)。在软件部分,点击 “选择PHP版本”。
3).tap“fileinfo”chexbox在php选项中,像下面的照片。
答
$base_path = $this->config->item('upload_path');
$config['upload_path'] = $base_path.'/folder_name/';
$config['allowed_types'] = config('allowed_extensions');
$config['max_size'] = config('max_upload_file_size');
$config['encrypt_name'] = true;
$file_name = '';
$this->load->library('upload', $config);
检查此代码。
+0
仍然相同问题 –
+0
是否将您的其他数据更新到db正确? –
答
在控制器
<?php
public function _upload_files()
{
$this->session->unset_userdata('upload_data');
$config['upload_path'] = FCPATH.'uploads'.DIRECTORY_SEPARATOR;
$this->_check_file_upload_path($config['upload_path']);// check if upload path exists, if not creates one
$config['allowed_types'] = "gif|jpg|png|jpeg";
$config['encrypt_name'] = TRUE;// file name will be encrypted
$this->load->library('upload', $config);
if (!$this->upload->do_upload('photo'))
{
echo $this->upload->display_errors('','');
return FALSE;
}
var_dump($this->upload->data());
}
private function _check_file_upload_path($upload_path)
{
if(! is_dir($upload_path))
mkdir($upload_path,0777,TRUE);
return $upload_path;
}
什么是错误? –
其未显示任何错误 –
检查您的服务器文件夹权限。它应该是777. image name正在更新到数据库中? –