[Fixed]: WordPress Image Upload Overwrites Existing Images
I have been uploading a lot of screen captures taken on my mac to my blog lately and recently noticed that WordPress seems to be overwriting the previous files I have uploaded with the same name.
Mac screen captures are saved the the desktop as “Picture 1.png” (”Picture #.png” # increments if there is already “Picture (#-1).png on my desktop) and when WordPress uploads the file it checks to make sure that it doesn’t already exist as “Picture 1.png” and then uploads it.
The problem is when WordPress uploads the file it changes it into “picture-1.png” by making it lowercase and adding a hyphen. The next time I go to upload the file “Picture 1.png” it looks for “Picture 1.png” which it doesn’t find because my previous file got changed to “picture-1.png”. Thus WordPress uploads the new file, changes it’s case while adding a hyphen, and thus overwriting my old file.
I did some searching and right away found a simple fix to the problem thanks to this thread in the support section on the WordPress site: http://wordpress.org/support/topic/161949
The file you need to edit is “wp-admin/includes/file.php”. Lines 170 and 171 need to be moved up to before the system checks for duplicate files. That way it checks to see if “picture-1.png” is already there and not “Picture 1.png”. Score!
Here’s a screenshot I took outlining how to fix the problem:
Hope this helps,
Nick
P.S. I just tested it for the first time on this post and sure enough it uploaded the file as “picture-11.png” instead of overwriting the existing “picture-1.png” I already had uploaded.

Grab a feed!
Buy me a coffee

