Hello, in this video, we are going to take a look at if the file already exists on our server. Because if we try and upload the file, and the file exists when I say the file or mean something with the same name and extension, even if it's not the same for if you have the same name, same extension will be considered the same file and it will get overwritten. So if you don't want it to be overwritten, and maybe you want to inform the user, or you just want to confirm from the user saying file already exists, do you want to replace it, you know, sort of how you get on your computer, if you try and copy and paste in a folder that has a file with the same name and extension? It's really simple to do. So after this, after we've checked the submit, we want to check if f file exists.
And all we do is target file and it's gonna say echo sorry file already exists. And we're gonna say upload status equals zero. So that means it will not get into here and even try and upload it. Now if I was to reload it go to. So I have a file called to dot png. If I try and do two dot png, I click Upload, this file is an image file already exists.
So yeah, sorry, the fall already exists. And blazer. And actually, you know, what I'm going to do is, I'm going to put a new line tag at the end of all of these, because it's just beginning hard to know see the different errors there, just because they're all on one line and nine spaces between them. Okay, so that's your producer thinking the same thing. But just with a better formatting, that will go back to that, sorry, the file exists. But if I try and upload number one, however, upload, it's been successfully uploaded.
And there we go. Number one is there. Well, so this is how you check if the file already exists. And you can handle that accordingly. As an extra task. What I want you to do is essentially ask the user, you know, file exists, do you want to proceed with the uploading, so you actually check in and if they say, yes, he overwrites the file and check by having a file that an image that is different, but has the same name so you can confirm that he has overwritten?
That's it any questions, feel free to pop me a message and as usual, I look forward to seeing you in the next video.