File 上载路径似乎无效”;。Codeigniter文件上载
如果我尝试上载文档文件,则会出现以下错误“上载路径似乎无效”。我将路径替换为绝对路径,然后我也得到了这个错误。File 上载路径似乎无效”;。Codeigniter文件上载,file,codeigniter,upload,File,Codeigniter,Upload,如果我尝试上载文档文件,则会出现以下错误“上载路径似乎无效”。我将路径替换为绝对路径,然后我也得到了这个错误。 请建议我如何解决这个问题。`将您的代码更改为$config['upload\u path']='uploads'调用$this->load->library('upload',$config)时通常会出现问题,原因可能是它没有加载配置设置,因此请在加载上载库后尝试添加以下语句 $config['upload_path'] = './uploads/';
请建议我如何解决这个问题。`将您的代码更改为
$config['upload\u path']='uploads'
调用$this->load->library('upload',$config)
时通常会出现问题,原因可能是它没有加载配置设置,因此请在加载上载库后尝试添加以下语句
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|docx';
$config['max_size'] = '400';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->referral_model->postCVReferralInfo($m_id, $emp_id , $job_id, $name, $age , $gender,$country_id, $mobile, $email, $summary, $workExp, $education, $qualification, $offer, $sb_id);
header('location:'.$this->config->base_url().'index.php/member/referSuccess');
exit;
} `
同样的问题…由
$this->upload->initialize($config);
最好不要在$CONFIG['UPLOAD\u PATH']中使用…BASE\u URL千万不要在$CONFIG['UPLOAD\u PATH']中使用BASE\u URL()
注意上传文件夹前反斜杠前的点。因此,您的上传路径应该如下所示
$this->upload->initialize($config);
更好地使用:
$CONFIG['UPLOAD_PATH'] = './assets/uploads/
并通过以下方式初始化配置:
$config["upload_path"] = $_SERVER['DOCUMENT_ROOT']."/your/desired/location/";
我也遇到了同样的错误,这是我的代码
$this->upload->initialize($config);
试图过去
// Upload Image
$config['upload_path'] = './uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '7048';
$config['max_width'] = '7000';
$config['max_height'] = '7000';
// Create folder (Uploads) if not exists
if (!is_dir($config['upload_path'])) {
mkdir($config['upload_path']);
}
// Load library Upload
$this->load->library('upload', $config);
// Initialize the Upload library with curront $config
$this->upload->initialize($config);
$this->upload->do_upload();
if ($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
$page_image = $_FILES['userfile']['name'];
} else {
$errors = array('error' => $this->upload->display_errors());
$page_image = 'noimage.jpg';
}
$this->page_model->create_page($page_image);
// Set message
$this->session->set_flashdata('page_created', 'Your page has been created');
redirect('admin/pages/create');
刚加载完库上传
$this->upload->initialize($config);
根目录上的上载文件夹在哪里???上载文件夹位于主文件夹内(应用程序文件夹、图像文件夹等位于主文件夹内),请确保目录可写。在其上设置了什么chmod?目录是可写的。只有当
$config['upload\u path']
为空(不是空)或php命令为\u dir(upload\u path)
返回false时,CodeIgniter才会返回该错误消息。因此,这表示无法找到定义的路径。检查以确保“uploads”文件夹与main index.php文件位于同一目录中,并且目录名称与案例相同(即uploads not uploads)。是的,在我的案例中,基本URL也是问题所在
$this->load->library('upload', $config);