Home  >  Article  >  Backend Development  >  How to modify image name in php

How to modify image name in php

藏色散人
藏色散人Original
2020-08-31 10:19:263799browse

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();

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!

Statement:
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