From the course: Building APIs in PHP Using the Slim Micro Framework

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Process file uploads via API

Process file uploads via API

From the course: Building APIs in PHP Using the Slim Micro Framework

Start my 1-month free trial

Process file uploads via API

- [Narrator] In this section, we're going to go ahead and figure out how to upload a file. Luckily, Slim has a few helpful functions, like get uploaded files and get client file name within the system itself to make things fast and easy. So, without further ado, let's try it. First, we're going to go over to our files section here, and create a new directory called assets. We want to make sure that when we upload a file, it has somewhere to go. Within that assets folder, let's go ahead and be a little bit more specific and create images. In case we have other assets later on, we'll have images sorted out already. We're already established that we need to go into the post messages route here, so we'll start there. We'll make the little bit of space for ourselves. Let's start with an image path. This will be wherever the final image ends up. And luckily, in our database itself on the messages table, we already have a space for that. We'll call this image URL, which is just the field…

Contents