Created
January 21, 2012 23:29
-
-
Save anabelle/1654509 to your computer and use it in GitHub Desktop.
Function to get an email using Sendgrid Parse API and save attachments using CodeIgniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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