jquery - return result from function and use results in another function php -
below code fileupload,
what want function return file path , file path, need use in sendemail function,
public function add_attachments($ticket_id) { $config['upload_path'] = './uploads/attach/'.$attach_id; $config['allowed_types'] = 'gif|jpg|png|jpeg|doc|pdf'; $config['max_size'] = '1024000000'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); } else { $data = $this->upload->data(); $file_name = $data['file_name']; } return $file_name; //echo base_url().'uploads/attach/' .$file_name; }
now above function return in $file_name, want use in same value in function, example send_email()
this 2 function executed simultaneously jquery in html, means upload attachments , send email attachments.
here jquery components,
function upload , submit,
$(".dropzone").dropzone({ paramname : 'userfile', autoprocessqueue: false, //maxfilesize : 0.1, url: "<?php echo base_url()?>index.php/upload/add_attachments/"+<?php echo $attach->attach_id; ?>, init: function() { var mydropzone = this; // here's change enyo's tutorial... $("#ticketreply_fm").submit(function(e) { e.preventdefault(); e.stoppropagation(); mydropzone.processqueue(); sendreply(); } );
sendreply() function send additional data ajax return,
thanks advanced,
i don't if i'm thinking problem, then
set private property called
private $file_name;
then in add attachment method use this:
public function add_attachments($ticket_id) { $config['upload_path'] = './uploads/attach/'.$attach_id; $config['allowed_types'] = 'gif|jpg|png|jpeg|doc|pdf'; $config['max_size'] = '1024000000'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); } else { $data = $this->upload->data(); $this->file_name = $data['file_name']; } return $this->file_name; //echo base_url().'uploads/attach/' .$file_name;
}
create public method file name like
public function get_file_name() { return $this->file_name; }
so can have value of file name using
get_file_name()
method.
i hope helped.
Comments
Post a Comment