# Sending files with Incoming Webhook

**URL:** <https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574>\
**Category:** Get Help\
**Tags:** webhooks, base64\_encode, json\
**Created:** [October 6, 2022, 10:33am UTC](https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574 "2022-10-06T10:33:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom.collins](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tom.collins](https://community.gravityforms.com/u/tom.collins)\
**Post date:** [October 6, 2022, 10:33am UTC](https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574/1 "2022-10-06T10:33:16Z")

</div>

Hi,

I have created an incoming webhook which creates a entry in GF, currently I am sending over user data which isn’t a problem but sometimes a file will need to be attached and sent then accessed from WP.

On my PHP script I have created the JSON which is sent over and added the attachment to this but I am not sure how this is going to send it, I hope that makes sense?

Below is my PHP variable encoding into JSON which is then sent to GF Incoming webhook via CURL.

```auto
$json_data = json_encode([
    // Message
    'emailSubject' => $emailSubject,
    'emailHtml' => $emailHtml,
    'emailMessageId' => $emailMessageId,
    'emailToAddress' => $emailToAddress,
    'emailFromAddress' => $emailFromAddress,
    'emailReplyToAddress' => $emailReplyToAddress,
    'emailSenderAddress' => $emailSenderAddress,
    'emailRecent' => $emailRecent,
    'emailUnseen' => $emailUnseen,
    'emailFlagged' => $emailFlagged,
    'emailMailDate' => $emailMailDate,
    'emailSize' => $emailSize,
    'attachment_1' => $attachments[0]['filename']
    

], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );

```

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [October 6, 2022, 10:33pm UTC](https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574/2 "2022-10-06T22:33:29Z")

</div>

Hi Tom. If your form uses a file upload field for single files (not multi-file) you can base64\_encode the file and send it like this:

```auto
'attachment_1' => base64_encode( file_get_contents( $attachments[0]['filename'] ),

```

**filename** here needs to be the full path to the file on the server.

If you have any other questions, please let us know.

---

<div class="post-metadata">

**Author:** ![tom.collins](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tom.collins](https://community.gravityforms.com/u/tom.collins)\
**Post date:** [October 7, 2022, 7:56am UTC](https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574/3 "2022-10-07T07:56:38Z")

</div>

Hi Chris,

Fantastic thank you very much, I will give that a go.

Much appreciated.

Tom

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [November 6, 2022, 7:56am UTC](https://community.gravityforms.com/t/sending-files-with-incoming-webhook/13574/4 "2022-11-06T07:56:57Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
