Mar 17 2015
Laravel 5 and simple Forms workaround
Here is a simple example of using laravel 5 powerful forms to deliver a secure and fast result!
To make our lives easier we need to install the HTML package!
In file /compojer.json we add:
"require": {
"laravel/framework": "5.0.*",
"laravelcollective/html": "~5.0"
},
Next add the service provider and aliases.
In /config/app.php we update the following:
'providers' => [ 'Illuminate\Html\HtmlServiceProvider', ], 'aliases' => [ 'Form'=> 'Illuminate\Html\FormFacade', 'HTML'=> 'Illuminate\Html\HtmlFacade', ],
Jul 6 2021
PHP – detecting new uploaded images and sending an e-mail with attachments
Quick example today if a php script that I wanted to detect new uploaded images, and then send an e-mail.
I think it’s pretty self-explanatory so won’t go into details. However, keep in mind that it’s mostly simple PHP (not too object-oriented) and also that I make use of the wp_mail function.
$menPath = "path-to-uploaded-files/*.jpg"; $menLast = file_get_contents('timestampFile.txt'); if($menLast === false){ echo 'it is zero'; $menLast = 0; } $menFiles = glob($menPath); $menFiles = array_filter($menFiles, function ($file) use ($menLast) { $mentest = $menLast - filemtime($file); return filemtime($file) > $menLast; }); file_put_contents('timestampFile.txt', time()); if (count($menFiles) > 0 ) { $menText = "images uploaded\r\nFound images count:".count($menFiles) ."Current last timestamp recorded:".date('d-m-Y h:i:s', $menLast )."\r\n" ."Images found:\r\n"; <code>foreach ($menFiles as &$file) { $menText = $menText.date('d-m-Y h:i:s', filemtime($file))."-".basename($file)."\r\n"; }</code> wp_mail( "[email protected]", "files-uploaded", $menText ,'',$menFiles); } ?>By Menelaos Bakopoulos • PHP, Scripts, Uncategorized 0