PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to prevent uploading duplicate file names?

  1. Hi, I have a contest where people can upload a picture to win a prize. The problem is, if two people post an image called "image.jpg", the newer post (I think) overwrites the older post.

    I'm running a validation function to prevent images that are too large or too small here:

    http://pastebin.com/jRT9wXwk

    On lines 27 and 28, I added a random number to the front of the file name, but I don't think it's working--even though when I look in the upload directory, I see the random number. Can you please tell me how to prevent duplicate files from being uploaded to the server? Thanks,
    Ben

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  2. David Peralty

    By default, our file uploader wouldn't allow duplicate names, it would append a -1 or -2 after them like WordPress' media uploader does, but because you've changed how things work, it isn't doing that. Not sure why your random file name generator isn't working. I can pass this thread to our developers to take a look though.

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  3. OK, I thought it had to prevent dupes, but I added that to make sure. What's happening is that some entrants are seeing other entrants' photos posted as their own. I can provide login creds if needed. Thanks so much for your help.

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  4. OK, I thought it had to prevent dupes, but I added that to make sure. What's happening is that some entrants are seeing other entrants' photos posted as their own. I can provide login creds if needed. Thanks so much for your help.

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  5. Hi guys, I really need help on this. The form software isn't working; it's allowing duplicates; some people's files are overwriting others' files. I don't know what else I can do on my end. Please help!!!

    Posted 11 years ago on Monday June 24, 2013 | Permalink
  6. What version of GF are you using? Can you please fill out a priority support form and include all necessary details and logins (FTP, WP Admin, phpmyadmin access) so we can take a closer look:

    http://www.gravityhelp.com/priority-support/

    Posted 11 years ago on Monday June 24, 2013 | Permalink
  7. OK, filling out a form now. Thanks!

    Posted 11 years ago on Monday June 24, 2013 | Permalink

This topic has been resolved and has been closed to new replies.