Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors',1); // enable php error display for easy trouble shooting
- error_reporting(E_ALL); // set error display to all
- $imagefolder = "new/new/uploads";
- $images = GLOB($imagefolder . "/" . "*{.jpg,.jpeg,.png,.gif}", GLOB_BRACE);
- foreach ($images as $img) {
- $file = $img;
- $fileparts = pathinfo($file);
- $path = $fileparts['dirname'] . "/newfiles";
- if (file_exists($path) === false) {
- mkdir($path, 0777, true);
- }
- $newfile = $path . '/'. date("Y-m-d", filemtime($img)) . "." . $fileparts['extension'];
- if (!file_exists($newfile)) {
- rename ($file, $newfile);
- $log = $path . "/log.txt";
- $data = "original file: {$file} to: {$newfile} status: Successful";
- } else {
- $data = "original file: {$file} to: {$newfile} status: Error, file exists";
- }
- file_put_contents($log, $data, FILE_APPEND); // create log file
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement