Dropzone.js - How to change file name before uploading to folder

后端 未结 3 499
有刺的猬
有刺的猬 2020-12-15 06:57

I am using DropzoneJS script for uploading images with drag & drop, but now I\'m looking for a solution for how to add current timestamps with file name before uploading

3条回答
  •  一生所求
    2020-12-15 07:17

    I just used the standard php file rename.

    $targetFile =  $targetPath . $_FILES['file']['name']; //the original upload
    $newfilename = "somename" . $variable . ".jpg"; //a new filename string
    
    rename($targetFile , $new); //rename at the end of the function

    This worked well for me and was pretty simple to implement. The .jpg extension is probably not recommended to hard code but in my scenario im only getting jpg file types.

提交回复
热议问题