1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<?php
namespace classes;
use DateTime;
use vendor\PhpEcho\PhpEcho;
use vendor\rawsrc\Request;
use classes\MYPDO; //to use class MYPDO
class csvUpload
{
private $type_file;
/* Constructor */
public function __construct()
{
$page = new PhpEcho([DIR_ROOT, 'view Layout.php']);
$body = new PhpEcho([DIR_ROOT, 'view formCsvUpload.php'], []);
$page['body'] = $body;
// on renvoie au navigateur la page assemblée
echo $page;
// one checks the extension, and if not csv, one exits
if (isset($_POST['submitfile1'])) {
$info = pathinfo($_FILES['file1']["name"], PATHINFO_EXTENSION);
if ($info!='csv') {
$body = new PhpEcho('', ['msg_error' => "this file is not a csv"]);
$body->setCode('<p>'.nl2br($body('msg_error')).'<br></p>');
echo new PhpEcho([DIR_ROOT, 'view Layout.php'], ['body' => $body]);
exit;
}
else
{
$body = new PhpEcho('', ['msg_end' => $_FILES['file1']["name"]." is uploaded"]);
$body->setCode('<p>'.nl2br($body('msg_end')).'<br></p>');
echo new PhpEcho([DIR_ROOT, 'view Layout.php'], ['body' => $body]);var_dump($_FILES['file1']);
return($_FILES['file1']);
}
} // end if (isset($_POST['submitfile1']))
} // end __construct
} //end class csvUpload |