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.

post image isn't attaching file image to a post

  1. rdpalmer
    Member

    It creates a new post draft and attaches to that instead.

    Posted 9 years ago on Thursday September 27, 2012 | Permalink
  2. rdpalmer
    Member

    I also want to specify my own filename for the image. Any help would be appreciated.

    Posted 9 years ago on Friday September 28, 2012 | Permalink
  3. Are you trying to accept and image upload and attach it to an existing post, or create a new post? Can you post a URL where the form is present and explain how this is supposed to work?

    Regarding renaming the image, please see this user's solution:
    http://www.gravityhelp.com/forums/topic/file-upload-location-and-name#post-76119

    Posted 9 years ago on Friday September 28, 2012 | Permalink
  4. rdpalmer
    Member

    Sorry I I don't have a url. But I will try and explain. I have made a simple form with just a 'post image' field', and no other fields, thats it. When I use the form I click on browse, select an image and then click the submit button. If I go into the dashboard and then view the file in the media library it shows it is there, but the file is attached to a new post called Untitled(which is a draft) which has been created at the same time as the image has been uploaded. Each new upload of an image is creating a new post (the subsequent uploads creates Untitled_1, then Untitled_2 both also drafts) in the posts section of the dashboard.

    I would have assumed that the image uploaded would have been attached to the post that the form was located on. This is what I want it to do.

    Thanks for your help I will try the link you sent me it looks like what I want for the filename change.

    Posted 9 years ago on Friday September 28, 2012 | Permalink
  5. rdpalmer
    Member

    I also have another issue.

    1) The upload is stored at "C:\Users\Robert\Documents\My Web Sites\wordpress\images" along with 3 other thumbnails which is all good.

    2) However the upload is also stored at "C:\Users\Robert\Documents\My Web Sites\wordpress\images\gravity_forms\3-114053b747e30d8285ea55ac533ae777\20129".

    I don't need/want the duplicate file that is being created in the \gravity_forms\ folder. From what I can tell it should only be a temporary file and should have been moved/deleted once it is in my folder at "C:\Users\Robert\Documents\My Web Sites\wordpress\images".

    Btw this is the default behaviour, without any hooks on my end.

    Posted 9 years ago on Saturday September 29, 2012 | Permalink
  6. Regarding your last reply, that is default Gravity Forms functionality. The file is uploaded and stored in the Gravity Forms uploads folder, and is then moved to the media library. This is because the link in the entry is to the file in the Gravity Forms folder, not the media library. Not all uploaded images go to the media library, so we have to use the Gravity Forms upload folder in all cases. Deleting the file from the Gravity Forms upload folder would break the link in the admin entry.

    Posted 9 years ago on Saturday September 29, 2012 | Permalink
  7. I would have assumed that the image uploaded would have been attached to the post that the form was located on. This is what I want it to do.

    This is not how you have it configured and not how Gravity Forms is designed to work. You have it configured to create a new post, which Gravity Forms is doing. The image which was uploaded is attached to the new draft post. It does not sound like this is what you want at all. You do not want to create a new post, you want to allow visitors to upload an image which will be attached to the post where the Gravity Form is embedded: is that accurate?

    Gravity Forms was not intended to be a post editor. However, you can make this happen. Because you want the image which is being uploaded attached to the current post, you already have everything you need. You have the post ID and you have the image, You just need to attach the uploaded image to the current post. You can do this with the gform_after_submission hook and the WordPress wp_insert_attachment function.

    http://www.gravityhelp.com/documentation/page/Gform_after_submission
    http://codex.wordpress.org/Function_Reference/wp_insert_attachment

    Posted 9 years ago on Saturday September 29, 2012 | Permalink