You must enable javascript in order to use Slack. You can do this in your browser settings.

Uploading files to Slack

When you upload a file to Slack, Slack becomes the host for your file, taking care of its safe storage. Uploading files is by far the easiest way to use files in Slack.

In order to upload a file to Slack, there's some scopes and events your app should pay attention to. Read our guide to app setup for a walkthrough.

Now that you're warmed up and ready to upload, let's get to the good stuff.

Uploading files

Your app can upload files using the files.upload method. Check out the method documentation for a deep dive on the details of available parameters.

Here's a sample curl command that uploads a file:

curl -F file=@cycling.jpeg -F "initial_comment=Hello, Leadville" -F channels=C0R7MFNJD -H "Authorization: Bearer xoxp-123456789"

As always, life is easier with a Slack SDK. Use your programming language of choice, and get methods like files.upload as primitive building blocks that you don't have to think about.

If you've got the necessary scopes, your file should appear in the channels specified.

A picture of a teapot

Here's a potentially confusing bit when you use the channels parameter during your upload: the upload method actually combines "uploading" (creating a file hosted in Slack), and "sharing" the file to a channel.

If you don't use the channels parameter, the upload method only "uploads" the file, hosting the file in Slack, but doesn't "share" the file anywhere.

Either way, once your upload succeeds, you'll see an HTTP response from Slack containing an "ok": true field, plus a file object. For more detail on file objects and the fields contained inside, a look at the file object documentation is highly recommended.

Other methods for working with files

Slack provides some other methods for working with files:

Responding to files

Slack also sends events when files are uploaded or changed in your workspace. Here are some of the relevant events:

The best thing about working with files is that they usually work the way you'd expect. Gone are the days of file comments (don't ask) and strange behavior.

If, however, you wish to flex your file skills by sharing files hosted outside of Slack, providing custom unfurls, or fine-tuning the way your files appear in Slack searches: continue onward to our guide on remote files.