Home > Backend Development > PHP Problem > How to modify image name in php

How to modify image name in php

藏色散人
Release: 2023-03-05 14:08:01
Original
3867 people have browsed it

How to modify the image name in php: first specify the file path through the "glob("20190505/*.jpg");" method; then use a foreach loop to traverse to obtain the image suffix name; finally modify the image name through the rename function That’s it.

How to modify image name in php

Recommended: "PHP Video Tutorial"

php batch modification of image names

//指定文件路径
$arr = glob("20190505/*.jpg");
//循环遍历
foreach($arr as $file) {
    //获取图片后缀名
    $ext = pathinfo($file,PATHINFO_EXTENSION);
    //重命名 
    rename($file,__DIR__.'/photo/'.$name);
}
die();
Copy after login

The above is the detailed content of How to modify image name in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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