How to rename uploaded file before saving it into a directory?

前端 未结 5 890
清酒与你
清酒与你 2020-11-22 03:20

Below is the code I used in order to upload files into a directory. It works fine. My main question is:

move_uploaded_file() is the one that saves t

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 03:58

    You can Try this,

    $newfilename= date('dmYHis').str_replace(" ", "", basename($_FILES["file"]["name"]));
    
    move_uploaded_file($_FILES["file"]["tmp_name"], "../img/imageDirectory/" . $newfilename);
    

提交回复
热议问题