application/controllers/Common.php
/*Function for upload shortlisted property image */
Function for upload shortlisted property image
Function for upload shortlisted property image
public function handle_property_image_upload() {
		$image = $this->post('propertyUrl');
	    $temp_file_path = tempnam(sys_get_temp_dir(), 'androidtempimage'); 
		file_put_contents($temp_file_path, base64_decode($image));
		$image_info = getimagesize($temp_file_path); 
		$_FILES['userfile'] = array(
		     'name' => uniqid().'.'.preg_replace('!\w+/!', '', $image_info['mime']),
		     'tmp_name' => $temp_file_path,
		     'size'  => filesize($temp_file_path),
		     'error' => UPLOAD_ERR_OK,
		     'type'  => $image_info['mime'],
		);
		$config['upload_path'] = './uploads/property';	    
	    $config['allowed_types'] = 'gif|jpg|jpeg|png';
	    $config['max_size'] = '2048';
	    $config['remove_spaces'] = TRUE;
	    $config['encrypt_name'] = TRUE;
	    $this->load->library('upload', $config);
	    $this->upload->initialize($config);
	    if($this->upload->do_upload_rest('userfile', true)) {
	        $arr_image_info = $this->upload->data();
	        $_POST['propertyUrl1'] = '/uploads/property/'.$arr_image_info['file_name'];
	        return true;
	    }else{
	       	$error = $this->upload->display_errors('', '');
	        $this->form_validation->set_message('handle_property_image_upload', $error);
			return false;
	    }
	}
public function handle_property_image_upload ( ) { $ image = $ this -> post ( 'propertyUrl' ) ; $ temp_file_path = tempnam ( sys_get_temp_dir ( ) , 'androidtempimage' ) ; file_put_contents ( $ temp_file_path , base64_decode ( $ image ) ) ; $ image_info = getimagesize ( $ temp_file_path ) ; $ _FILES [ 'userfile' ] = array ( 'name' => uniqid ( ) . '.' . preg_replace ( '!\w+/!' , '' , $ image_info [ 'mime' ] ) , 'tmp_name' => $ temp_file_path , 'size' => filesize ( $ temp_file_path ) , 'error' => UPLOAD_ERR_OK , 'type' => $ image_info [ 'mime' ] , ) ; $ config [ 'upload_path' ] = './uploads/property' ; $ config [ 'allowed_types' ] = 'gif|jpg|jpeg|png' ; $ config [ 'max_size' ] = '2048' ; $ config [ 'remove_spaces' ] = TRUE ; $ config [ 'encrypt_name' ] = TRUE ; $ this -> load -> library ( 'upload' , $ config ) ; $ this -> upload -> initialize ( $ config ) ; if ( $ this -> upload -> do_upload_rest ( 'userfile' , true ) ) { $ arr_image_info = $ this -> upload -> data ( ) ; $ _POST [ 'propertyUrl1' ] = '/uploads/property/' . $ arr_image_info [ 'file_name' ] ; return true ; } else { $ error = $ this -> upload -> display_errors ( '' , '' ) ; $ this -> form_validation -> set_message ( 'handle_property_image_upload' , $ error ) ; return false ; } }
Function for upload shortlisted property image
Function for upload shortlisted property image
// might not work on some systems, specify your temp path if system temp dir is not writeable