In the $_FILES global variable, when i used
$_FILES["file"]["name"]: I am getting the name of the file which i am uploading.$_FILES["file"]["type"]: Here i am getting blank data. But when i used ISSET function on this variable (isset($_FILES["file"]["type"])), it’s returning 1.$_FILES["file"]["size"]: It returning zero.
I really don’t know, what is the real cause of this issue?
(As i am observing this issue is not happening in case of creating a new record, i.e., add a new record in the table and upload the specified file to the server.
But, the said problem is happening only when i try to edit an existing record i.e., replacing the old file with a new file by uploading the new file.)
From the manual…
If no file is selected for upload in your form, PHP will return $_FILES['userfile']['size'] as 0, and $_FILES['userfile']['tmp_name'] as none.Also, isset returns true when you check
$_FILES["file"]["type"]because it is set, that is the variable exists, but its value is empty. Instead of isset, useif (empty($_FILES["file"]["type"]))You should not trust
$_FILES["file"]["type"]either as it can either be spoofed by the user, or just plain wrong.Do you get the above errors only if no file was uploaded? Or was a file uploaded? It may be that there was an error with the file so those parts of the array were not set.
Post some more code and a more descriptive explanation of the problem and how you can reproduce it and we can help more.