php Unique filename when uploading

后端 未结 5 1588
生来不讨喜
生来不讨喜 2020-12-11 04:14

I\'ve a submit discussion form with image upload in my website. Now, I want to upload a unique file name when the user submits their image so that I can show the result of a

5条回答
  •  一生所求
    2020-12-11 04:31

    I think the simplest way would be to store the image name in a database field and then when the user is uploading their image to validate that the file name is unique by checking it against existing filenames. You can use an ajax / jquery interface if you don't want the user to have to wait til the form has been submitted to get an error or prompt to change their filename.

提交回复
热议问题