EllisLab text mark
Advanced Search
     
File (Image) Upload
Posted: 11 November 2012 12:14 PM   [ Ignore ]
Avatar
Joined: 2012-11-10
4 posts

See my Code,

$docidn $this->input->post('doc_identity'); //reference to the private function
    
$docres $this->input->post('doc_residence'); //reference to the private function
    
if($docidn != ""
     
$doc_idn $this->upload_docs_idn();
    else
     
$doc_idn NULL;
    if(
$docres != '')
     
$doc_res $this->upload_docs_res();
    else
     
$doc_res NULL

The functions

private function upload_docs_idn(){
 
/**
  * Upload the necessary Documents (Identity)
  * returns the full path of the file_location
  **/
  
$config['upload_path''http://localhost/direct/uploads/docs_identity';
  
$config['allowed_types''gif|jpg|png';
  
$config['max_size''2048';
  
$config['encrypt_name'TRUE;

  
$this->load->library('upload'$config);
  
  
$this->upload->do_upload('doc_identity');
  
$data $this->upload->data();
  return 
$data['full_path'];
 
}
 
 
private function upload_docs_res(){
 
/**
  * Upload the necessary Documents (Proof of Residence)
  * returns the full path of the file_location
  **/
  
$config['upload_path''http://localhost/direct/uploads/docs_residence';
  
$config['allowed_types''gif|jpg|png';
  
$config['max_size''2048';
  
$config['encrypt_name'TRUE;

  
$this->load->library('upload'$config);
  
$this->upload->do_upload('doc_residence');
  
$data $this->upload->data();
  return 
$data['full_path'];
 

$docidn is always NULL, even If I select a file :/ what could be the problem ???

 Signature 
 
Posted: 11 November 2012 11:15 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-11
166 posts

because $docidn is a $_FILES not a $_POST.

 
Posted: 12 November 2012 07:55 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2012-11-10
4 posts

now It works :/ though files are not uploaded, and this is returned

http://localhost/direct/uploads/docs_identity/

???

 Signature 
 
Posted: 14 November 2012 08:15 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2012-11-10
4 posts

bump

 Signature 
 
Posted: 14 November 2012 09:33 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-11-14
2 posts

function do_upload()
{//Instead of $config[‘upload_path’] = ‘http://localhost/mysite/mydiirectory’
  $config[‘upload_path’] = ‘./uploads/’;//use this for directory

  $config[‘file_name’]=$_FILES[‘userfile’][‘name’];
  $config[‘allowed_types’] = ‘gif|jpg|png’;
  $config[‘max_size’] = ‘2000’;
  $config[‘max_width’]  = ‘680’;
  $config[‘max_height’]  = ‘480’;

  $this->load->library(‘upload’, $config);
......}

 
Posted: 14 November 2012 10:25 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2012-01-09
117 posts
KrYpToNiT3 - 12 November 2012 07:55 AM

now It works :/ though files are not uploaded, and this is returned

http://localhost/direct/uploads/docs_identity/

???

You know only you can access your localhost, right?

 
Posted: 15 November 2012 03:47 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-11-14
2 posts

is your file upload directory…/uploads/docs_identity/ or what is it?? try referencing it as
$config[‘upload_path’] = ‘./uploads/docs_identity’;//use this for directory