How can I add a time stamp to a file name uploaded with $_File before the file extension

后端 未结 2 1886
闹比i
闹比i 2021-02-07 09:41

I have the following code

$image_path = $_FILES[\"p_image\"][\"name\"].time();

it names the file image02.jpg1335279888

bu

2条回答
  •  無奈伤痛
    2021-02-07 10:12

    $path_parts = pathinfo($_FILES["p_image"]["name"]);
    $image_path = $path_parts['filename'].'_'.time().'.'.$path_parts['extension']
    

提交回复
热议问题