Get db field value to gc list data

i dont understand !
the function set_upload_field(‘field’,‘assets/files/upload’, ‘pdf’)
but i debug code :

public function set_field_upload($field_name, $upload_dir = ‘’, $allowed_file_types = ‘’)
{
$upload_dir = !empty($upload_dir) && substr($upload_dir,-1,1) == ‘/’
? substr($upload_dir,0,-1)
: $upload_dir;
$upload_dir = !empty($upload_dir) ? $upload_dir : ‘assets/uploads/files’;

  /** Check if the upload Url folder exists. If not then throw an exception **/
  if (!is_dir(FCPATH.$upload_dir)) {
  	throw new Exception("It seems that the folder \"".FCPATH.$upload_dir."\" for the field name
  			\"".$field_name."\" doesn't exists. Please create the folder and try again.");
  }

  $this->upload_fields[$field_name] = (object) array(
  		'field_name' => $field_name,
  		'upload_path' => $upload_dir,
  		'allowed_file_types' => $allowed_file_types,
  		'encrypted_field_name' => $this->_unique_field_name($field_name));
  return $this;

}

the argument ‘pdf’ don’t pushed to $allowed_file_types at the defined function.

why ?

i found a solutions about allowed file types per field !
but i have another problem.

I defined this function :

function _callback_before_upload($files_to_upload,$field_info){

		/*debug code */
		//$_SESSION['pkey'] = $pkey;
		$_SESSION['files_to_upload'] = $files_to_upload;
		$_SESSION['field_name']= $field_info->field_name;
		if($field_info->field_name == 'file_url')
		{

			foreach($files_to_upload as $value) {
	        	$ext = pathinfo($value['name'], PATHINFO_EXTENSION);
	    	}

	    	$allowed_formats = array("pdf");
		    if(in_array($ext,$allowed_formats))
		    {
		        return true;
		    }
		    else
		    {
		        return 'Wrong file type. Only pdf files are allowed! ';    
		    }
		}//if

}

inside this function, I want to get the primary key . how can I get it ?

hello panv,
i have written this code :

                                if ( $state == 'edit') {

				$pkey = $info->primary_key;

				$this->db->where('id', $pkey);
				$q = $this->db->get('docs');
				$r1 = $q->row();

				$p1 = 'assets/uploads/files/'.$r1->folder_file;
				$_SESSION['p']=$p1;
				$crud->set_field_upload('file_url',$p1);				
			//$crud->set_field_upload('file_url',$this->verify_path_callback($path));
				$crud->set_field_upload('zip_file_attach',$p1);
				//$crud->set_field_upload('zip_file_attach','assets/uploads/files/2021');
				//$crud->callback_before_upload(array($this,'_callback_before_upload'));
			}

ignore comments.
I dont understand why $crud->set_field_upload(‘file_url’,$p1) when i try to upload a file , cant get the full path from value $p1 so the function set_field_upload gets only the default path ‘assets/upload/files’.

why ? what is going wrong? the session value is for testing.

I will appreciate it if you answered me!

I am so sorry that I was away for so long. I had to attend to personal issues, and was away from my computer all that time. Please do you still need help in this, so I could look it up ?

Hello panv ,
yes, I didn’t find full solution about this.

I had to attend to other issues from other applications.

I solved it but I have another issue with state == edit

i have opened a new post :

if you can sneak a peek with this … i have posted segments with my code…

thank you in advance.

I think the set_field_upload works serially . it creates the link between file upload and the path of each record.. .