You can check if the file has been uploaded to the server using different attributes provided by the PHP. For example, if you dont want to allow your users to upload the same file again and again, you can put a restriction on the user to upload new files only. We can set limit on the size of the file to be uploaded by adding an <input> element with the NAME attribute set to MAX_FILE_SIZE and the VALUE to the upper limit. I haven't demonstrated this in my sample code but here the piece of code for your reference:
<input type=hidden name=MAX_FILE_SIZE value=1024>
<imput type=file name=userfile>
Remember, the hidden <input> tag should precede the file <input> tag.
Place a check before displaying a message, use the empty() function to check if $userfile variable contains something or not, if its empty then display the message telling the user that the file hasn't been uploaded otherwise display the message that the file has been uploaded successfully. And that's it!
Comments