Home > Backend Development > PHP Tutorial > PHP implementation code for classifying and storing images according to creation time_PHP tutorial

PHP implementation code for classifying and storing images according to creation time_PHP tutorial

WBOY
Release: 2016-07-21 15:42:11
Original
826 people have browsed it

Copy code The code is as follows:

/*
Code function: Use PHP to cleverly press the image The creation time is classified and stored;
The image file attribute must cancel the read-only attribute, otherwise it cannot be deleted
By lost63
*/
//Delay setting
set_time_limit(0);
$path='C:Recover File Graphics $Picture JPEG Image (.jpg)';
$result=dir($path);
while($value=$result->read()){
if(strpos($value,'.JPG')==true||strpos($value,'.jpg')==true||strpos($value,'.gif')==true||strpos ($value,'.png')==true){
//If the folder does not exist, create it;
$fileNewPath=$path.'\'.fileTime($path.'\'.$ value);
if(!file_exists($fileNewPath)){
mkdir($fileNewPath);
}
moveFile($path.'\'.$value,$fileNewPath.'\' .$value);
}
}
//Get the file modification time
function fileTime($str){
return date("Y-m-d",filemtime($str));
}
//Move the file to a new address
function moveFile($file,$path){
copy($file,$path);
echo $file.'Location update completed< ;br>';
unlink($file);
echo $file.'The original location file has been deleted';
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321032.htmlTechArticleCopy the code as follows: ?php /* Code function: Use PHP to cleverly classify and store images according to their creation time; The image file attribute must cancel the read-only attribute, otherwise it cannot be deleted By lost63 */ /...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template