Home >Backend Development >PHP Tutorial >Move files to a directory and create the folder if it does not exist.
function hover_file($file_url,$file_name){
//Determine and create the folder
$y=date('Y',time());//Year
$m=date('m',time()) ;
if(!is_dir('../../../attachment/images/'.$y.$m)){
mkdir('../../../attachment/images/'. $y.$m,0777);//The folder with the creation year + month has the highest permissions
}
//Get the image path and move it
$text=$file_url;//Picture path 1
// $file_url;
// $file_url;
$text1=$file_name;//Picture path 2
$text1;
rename(iconv("UTF-8","GBK",$text),iconv("UTF-8","GBK ",$text1));
}
//-
The above has introduced how to move files to a certain directory and create the folder if it does not exist, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.