Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function to get an email using Sendgrid Parse API and save attachments using CodeIgniter
<?php
# CI Reference: http://codeigniter.com/user_guide/libraries/file_uploading.html
# SendGrid Reference: http://docs.sendgrid.com/documentation/api/parse-api-2/
public function input(){
//file upload configuration
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '8192';
$config['max_width'] = '0';
$config['max_height'] = '0';
//load the upload library
$this->load->library('upload', $config);
if(intval($_POST['attachments']) > 0){
if(intval($_POST['attachments']) == 1){
if ($this->upload->do_upload('attachment1')){
echo 'subio';
}else{
echo $this->upload->display_errors();
}
}else{
$cont = 1;
while($cont <= intval($_POST['attachments'])){
//repeat the action for each file
if ($this->upload->do_upload('attachment'.$cont)){
echo 'subio';
}else{
echo $this->upload->display_errors();
}
//go to the next file
$cont++;
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.