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.

Changing the path for image upload

  1. Hi

    I am using the plugin as an entry form for photographic competitions. I can at times be running several different competitions at the same time and for extended time periods. (Each one has it's own entry form)

    I use nextgen gallery to organise the photos and can specify a directory in nextgen to store the images.

    1. How do I specify a different folder for each form to upload to?
    wp-content/uploads/gravity_forms/(form_id)/ will be fine if I can lose the year and month sub folders.

    2. How do I stop the image upload copying the file to the media library as well?

    Thanks
    Greg

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  2. 1) You can change the file upload path using a hook and custom PHP. The documentation for the hook you need to use can be found here:

    http://www.gravityhelp.com/documentation/page/Gform_upload_path

    It wants the FULL ABSOLUTE PATH on the server to the folder as well as an HTTP url where the file can be accessed via the browser.

    2) Currently there is no way to stop the Media Library interaction if you are using the Post Image field. If you don't want images added to the Media Library then you can use the File Upload field or the Post Custom Field set to File Upload as the field type.

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  3. What should the code look like if I want to use this this path

    server/photocommment/wp-content/uploads/gravity_forms/(form_id)/
    http://photocomment.net/wp-content/uploads/gravity_forms/(form_id)/

    Once this code

    <?php
    add_filter("gform_upload_path_5", "upload_path");
    ?>

    has been changed to point to a specific directory for that specific post can I add it mulitple times just changing the form id and paths?

    Thanks
    Greg

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  4. What should the code look like if I want to use this this path

    server/photocommment/wp-content/uploads/gravity_forms/(form_id)/
    http://photocomment.net/wp-content/uploads/gravity_forms/(form_id)/

    Once this code

    <?php
    add_filter("gform_upload_path_5", "upload_path");
    ?>

    has been changed to point to a specific directory for that specific post can I add it mulitple times just changing the form id and paths?

    Thanks
    Greg

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  5. I can't tell you what the absolute path should look like because it's unique to your server. You would have to check with your web host for what the absolute path to a certain folder is going to be. You also need to make sure that folder exists and has the proper file permissions to allow it to be written to by the PHP (chmod 755 or chmod 777).

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  6. m.cabiles
    Member

    Hey Carl,

    I'm not sure where to post this question, but I hope you can help me out on this issue...

    RE: FILE UPLOAD PATH

    Specifically, the form was initially created on a test folder of the main domain <i.e., URL/test> but after copying the files to the main domain, and making necessary changes to point "URL/test" to "URL", the notification message shows that the uploaded file(s) is in the main domain's folder (which I expect it to be) but the file is still uploaded in the test folder... so when I click to the link <URL/file_path>, there's a 404 error, but when I access the file through the test folder <URL/test/file_path>, it works.

    I tried removing the files and re-installing the plugin, and recreating the form, but it didn't help. It still uploads to the test folder.

    Now, my question is: what needs to be done so that the file gets uploaded to the main domain folder and not to the test folder?

    THANK YOU for your immediate response.

    Posted 13 years ago on Tuesday July 5, 2011 | Permalink
  7. @m.cabiles Gravity Forms uploads files to your wp-content/uploads folder by default. Do you have custom code in place telling it to upload the files elsewhere? Because that is what this forum thread is discussing.

    Posted 13 years ago on Tuesday July 5, 2011 | Permalink
  8. m.cabiles
    Member

    Hi Carl,

    I understand... but I don't see a place where to post a new discussion thread... if you'd be so kind enough to direct me to the correct thread, that would be awesome.

    Anyway, I don't have a custom code... my issue is that any upload goes to the test folder (URL/test/wp-content/uploads/...) and not to the main domain file path (URL/wp-content/uploads/...).

    Thank you for your help.

    Posted 13 years ago on Tuesday July 5, 2011 | Permalink
  9. The uploads go to where WordPress is telling Gravity Forms your upload folder is. So if they are going to URL/test/wp-content/uploads it is because your WordPress site is configured to use this as your upload folder. Check your path settings in the Media settings under the Settings menu in the WordPress Dashboard. There is a path option for the Upload folder where you can set the path.

    Posted 13 years ago on Tuesday July 5, 2011 | Permalink
  10. m.cabiles
    Member

    Thanks, Carl! Setting the path under Media Settings worked! You're awesome!

    Posted 13 years ago on Monday July 11, 2011 | Permalink