PHP: If go to upload an image exist already and sometimes want replacement what code? if this is the default, please tell me for: if not want replacement what code?

Recommended Answers

All 3 Replies

yes this is default behavior of PHP file uplaod script, if file is already existed there then it will overwrite your old file.

For avoid this, you need to append some unique string in your file name like "time()" so if your image name is like "abc.jpg" then it will converted in "abc1292872879.jpg" so next time if same image will upload ten it will be unique with time() variable.

Best luck..

how understand that files currently exist in the folder on server so take the latter action you refer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.