PHP to store the picture by the time it was created _php the implementation code

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

<?php
/*
Code features: Use PHP to skillfully store pictures by creation time;
Picture file properties must cancel read-only property, otherwise you cannot remove
by lost63
/
//Delay setting
Set_time_limit (0);
$path = ' c:\ recovery 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) {
//Set up if the folder does not exist;
$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 file to new address
function MoveFile ($file, $path) {
Copy ($file, $path);
Echo $file. ' Location update complete <br> ';
Unlink ($file);
Echo $file. ' Original location file deleted ';
}
?>

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.