Store the implementation code for the Web using PHP to classify pictures by creation time

Source: Internet
Author: User
Tags filetime
Copy CodeThe code is as follows:


/*
Code features: Use PHP to skillfully set the image by the time of creation to classify storage;
The picture file property must be removed from 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, it is established;
$fileNewPath = $path. ' \ \ '. FileTime ($path. ' \ \ '. $value);
if (!file_exists ($fileNewPath)) {
mkdir ($fileNewPath);
}
MoveFile ($path. ' \ \ '. $value, $fileNewPath. ' \ \ '. $value);
}
}
Get File modification Time
function FileTime ($STR) {
Return date ("Y-m-d", Filemtime ($STR));
}
Move a file to a new address
function MoveFile ($file, $path) {
Copy ($file, $path);
echo $file. ' Location update complete
';
Unlink ($file);
echo $file. ' Original location file deleted ';
}
?>

The above describes the storage for the web format used by PHP to classify the image by the creation time to store the implementation of the code, including storage for the web in the format of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.