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.

Get File Path of File Upload

  1. Is there a way to get the path of the file uploaded from a "File Upload" field?

    I'd like to get the file after the form submission and populate another field in the form with the information. But I can't figure out the "hook" to grab the file field.

    Posted 9 years ago on Thursday April 18, 2013 | Permalink
  2. David Peralty

    You could set the path using the following hook:

    Then you would always know where it is going to be uploaded.

    Posted 9 years ago on Friday April 19, 2013 | Permalink
  3. Yes. I'm doing that actually.

    BUT... if someone uploads a file of the same name it ends up renaming it with a sequential number after the form is submitted... but the form only knows to use the name of the file that's uploaded.

    So, for example. someone uploads a file "myfile.pdf"
    The file uploads to my directory and the PHP grabs the file that was uploaded. But... when someone uploaded the same file again WordPress (or whatever) doesn't overwrite it. So the NEW file becomes "myfile1.pdf" but the Gravity Forms still reads you uploaded "myfile.pdf" so the link goes to the "old" file.

    Like this...

    I need a way to get the link of the actual file that was uploaded.

    Posted 9 years ago on Friday April 19, 2013 | Permalink
  4. If you can get the lead id of the submission you could query for the lead detail that has the filename in it. that would give you a full path. this is all AFTER it's been stored of course.

    Posted 9 years ago on Friday May 3, 2013 | Permalink