0
我有一個表來存儲它所顯示的文件鏈接:(文檔) 它是這樣的:如何在codeigniter中回顯用戶上傳的文件?
id | user_id | orig_name | file_name
pdf文件上傳正確,但對於user_id它給了我不變的價值。
我的目標是與上傳管理的privilages一個文件,然後可以到不同的PDF文件展示給不同的用戶,與連接USER_ID id爲會話
我做存儲的用戶ID的會話。 $這 - >會話級>用戶數據( 'USER_ID')
這裏是我的上傳 contorller:
function index()
{
$this->load->view('upload_form', array('error' => ' '));
}
function do_upload()
{
$config['upload_path'] = 'uploads';
$config['allowed_types'] = 'pdf';
//$config['max_size'] = '10000';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if (! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$upload = $this->upload->data();
$data['upload_data'] = $upload;
$user_id = $this->session->userdata('user_id');
//do I need the user's id or the admin? only the admin can upload files. (admin user is in a different table)
$this->db->set('user_id', $user_id);
$this->db->set('file_name', $upload['file_name']);
$this->db->set('orig_name', $upload['orig_name']);
$this->db->insert('documents');
$this->load->view('upload_success', $data);
}
}
謝謝你幫我出去! 我試圖說清楚,所以如果它有點複雜,那麼請問,我會回答。
非常感謝您的幫助!
目前還不清楚你在問什麼。請編輯你的問題來掩蓋它。 –
進行了更改 – gazrobur