上载路径在CodeIgniter 3中似乎无效



我有一个CodeIgniter项目假设2nd_c,在另一个CodeIgniter项目中假设1st_c。我想上传文件和图像到1stc项目,但它抛出路径错误"上传路径似乎不是有效的";我有负载";上传";图书馆,这是我的代码

$config=array();
$config['upload_path'] = '../assets/uploads/jobs';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['overwrite']     = false;
$config['max_size']      = 3000;
$config['remove_spaces'] = true;
$config['max_filename']   = 10;
$config['file_ext_tolower'] = true;

$this->upload->initialize($config);

if($this->upload->do_upload('pic')){
$udata = array('upload_data' => $this->upload->data());                
$jobimage = $udata['upload_data']['file_name'];            
$data['j_image'] = $jobimage;     
}else{
$errors = $this->upload->display_errors();
echo "<pre>"; print_r($errors); echo "</pre>";
exit;
}

"资产/上传/作业";这是在我的1stc项目中,它在localhost上运行良好,但在服务器上会抛出错误。我尝试过";FCPATH";但没有运气。

在处理CI文件夹时使用APPPATHbase_url()

$file_path = realpath(APPPATH . '../assets/uploads/jobs');

$file_path = base_url().'/assets/uploads/jobs');

文件夹结构应为

Application
assets
uploads
jobs
system
index.php
$upload_path = "Test_folder/Temp_folder";
public function upload($upload_path,$name){
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'pdf';
$config['max_size'] = 0;
$config['file_name'] = $name;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('file'))
{
return "true";
}
else{
$file_data = $this->upload->data();
$file_name = $file_data['file_name'];
return $file_name;
}
}

相关内容

  • 没有找到相关文章

最新更新