 Hey everybody it's Brian and welcome to the 26th tutorial. Today we're going to be handling multiple file uploads. Alright well if you hear some chimey music in the background that's my dryer just ignore that. Alright we're going to grab our last tutorial and literally copy and paste it in here. If you missed my last tutorial don't worry we're going to go over that. Okay the last tutorial we handled how to upload a single file and some key points to remember here is the ink type has to be multi-part form data and what happens is when you submit the page it is posted to the web server and the web server hands it off to PHP who says hey a file upload's going going on here and it creates this global variable called files and it uploads it to a temp name and once the uploads complete hand you the variable and you can do whatever you want. There's some properties in the multi-dimensional array like name type size, temp name. So what we're going to do here is we're just going to get rid of this. We'll probably need that. My mouse is going crazy on me. There we go. Make sure you type 26.php instead of 25 you'll be posting the old file and one thing you want to note is to add the brackets right here and you'll see why in just a second leave a little space there. You know how we've got two input types or I'm sorry two file inputs both of them named file bracket. Well what we're doing is we're adding another dimension to the array. Save it. Notice how we have two of them now. Now we simply want to grab the information that's uploaded. So we're going to say for each. We want to grab the id column and the name column and then we want to just simply print this out real quick here. That way we can verify that we are indeed getting multiple files here. So let's browse. Just grab icon one and icon two. Submit this. File array. Seems I admitted something. I'm very sorry about that. Remember we are taking a segment of the array and we need to match that up. There we go. That should work. My bad. Okay there we go. Zero icon one JPEG and one icon two JPEG. Let's actually add a hard return in here so you can really see what's going on here. Okay so there's our two files that we uploaded. Icon one. Icon two. In case you're wondering what this little bit of voodoo magic is basically we're just grabbing the information out of here. The actual array. Actually let me grab this. This would be much easier to show you. Just going to add some horizontal lines in there. Now you're used to this right here. A single uploaded file. What we've done with these brackets is we've added another dimension to this array. This is why we grabbed the identifier. Save our work and there we go. Let me move this up a little bit so you can see it here. So here's our first file icon one and here's our second file. Actually seems like I've goofed something up. Yes. Let me comment that out. Clean this up a little bit better. There we go. There's our first file icon one. There's our second file icon two. You can see the sizes are different and there are different temp names. So that's how you grab multiple files. Now there is a maximum file. Upload limit I should say. That's in PHP. It's in the PHP config file. Admittedly I do not know what that is because I tend to not allow users to upload too many files at once. Let's just grab this one and let's grab something that's not a JPEG. Let's grab that guy. So you can see how we can upload multiple files now. And then pretty much if you wanted to manipulate these files you would use as we did in the 25th tutorial the move uploaded files function which you just need a source and a destination. And remember the source should always be your temp name. In our case it's going to be the temp name and then the identifier. A lot of you are probably going to message me and ask, hey, how do you upload multiple files through a single dialog box like you do on Facebook or something like that? To be brutally honest I don't know. I think you need a flash animation to do that. I'm not quite sure but I don't think that functionality is actually built into PHP. I could be wrong and I'm going to research that a little bit. So that's all for this tutorial. This is Brian. Hope you found this educational entertaining and thank you for watching.