I have the following code
$image_path = $_FILES["p_image"]["name"].time();
it names the file image02.jpg1335279888
but i want it to be named image02_1335279888.jpg
How can I achieve that?
I have the following code
$image_path = $_FILES["p_image"]["name"].time();
it names the file image02.jpg1335279888
but i want it to be named image02_1335279888.jpg
How can I achieve that?
$path_parts = pathinfo($_FILES["p_image"]["name"]);
$image_path = $path_parts['filename'].'_'.time().'.'.$path_parts['extension']
你可以检查这个:
$file = $_FILES["p_image"]["name"];
$array = explode('.', $file);
$fileName=$array[0];
$fileExt=$array[1];
$newfile=$fileName."_".time().".".$fileExt;
$image_path = $_FILES["p_image"]["name"];
$extension = pathinfo($image_path)['extension'];
$file = "image02_".time().".".$extension."";
echo $file;
输出:
image02_1641041826.jpg