Example #1
0
<?php

$oUploads = new weeUploads();
foreach ($oUploads->filter('myfiles') as $oFile) {
    doSomething($oFile);
}
Example #2
0
            empty($_GET['upload']) or burn('IllegalStateException', _WT('No file was uploaded. Stopping here in order to prevent recursive execution.'));
            // Note: cURL does not seem to support arrays of fields (example: more[])
            $r = curl_init();
            curl_setopt($r, CURLOPT_URL, $sURL);
            curl_setopt($r, CURLOPT_POST, true);
            curl_setopt($r, CURLOPT_POSTFIELDS, array('test' => '@' . dirname(__FILE__) . '/test.txt', 'more' => '@' . dirname(__FILE__) . '/more.txt', 'evenmore' => '@' . dirname(__FILE__) . '/evenmore.txt'));
            curl_exec($r) or burn('UnitTestException', sprintf(_WT('Upload failed: %s'), curl_error($r)));
            curl_close($r);
            exit;
        } else {
            $o->exists('test') or burn('UnitTestException', _WT('The uploaded file "test" does not exist.'));
            $o->exists('more') or burn('UnitTestException', _WT('The uploaded files "more" does not exist.'));
            $o->exists('evenmore') or burn('UnitTestException', _WT('The uploaded files "more" does not exist.'));
            $i = 0;
            foreach ($o as $oFile) {
                $oFile->getExt() == 'txt' or burn('UnitTestException', _WT('The extension of the uploaded file is incorrect.'));
                $i++;
            }
            $i == 3 or burn('UnitTestException', _WT('The iteration should have passed over 3 different files.'));
            $i = 0;
            foreach ($o->filter('more') as $oFile) {
                $i++;
            }
            $i == 1 or burn('UnitTestException', _WT('The iteration should have passed over only 1 different file.'));
        }
    }
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}
echo 'success';