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

后端 未结 2 1833
闹比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:30

    You can check this one:

    $file = $_FILES["p_image"]["name"];
    $array = explode('.', $file);
    $fileName=$array[0];
    $fileExt=$array[1];
    $newfile=$fileName."_".time().".".$fileExt;
    

提交回复
热议问题