Example #1
0
<?php

require '../api.php';
$echo = new EchoPHP();
/**
 * Authenticate for this session.
 * For debugging, force an authentication each time.
 */
if ($echo->config->debug_mode) {
    session_start();
    unset($_SESSION['echophp_session']);
    session_destroy();
}
$echo->initSession();
/**
 * Handle the .csv file upload and add cards individually
 */
if (!empty($_FILES)) {
    // validate the file upload
    try {
        // if $_FILES is undefined/missing/corrupt, treat it as invalid
        if (!isset($_FILES['file'])) {
            throw new \RuntimeException('Something is wrong with the file.');
        } else {
            if (!isset($_FILES['file']['error']) || is_array($_FILES['file']['error'])) {
                throw new \RuntimeException('Something is wrong with the file.');
            } else {
                $file = $_FILES['file'];
            }
        }
        // check for any error with the upload