I have a form in which I have the following field : <input class="form-field" type="file" name="photo" />
how I can get the information from this field to be used in a if cycle in php ? if ($photo != '') {
It's in the $_FILES superglobal.
Incidentally, file uploads won't work unless
multipart/form-data
.You can find this info into the $_FILES superglobal.
Example:
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// your ($photo != '') is here
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
...
}
POST method uploads You can check this examples of how to works $_FILES, sorry for my bad english