Reputation: 89
I am try to check whether user choose uploaded file or not
html
<input type=\"file\" name=\"upload1[]\" multiple />
php
if(is_uploaded_file($_FILES['upload1']['tmp_name'])){
echo 'ok';
}
I am testing using it doesn't work. is there any other way
Upvotes: 0
Views: 297
Reputation: 256
Check this
<form enctype="multipart/form-data" method="POST">
Choose a file to upload:
<input type="file" name="upload1[]" multiple />
<br />
<input type="submit" value="Upload File" name="submit" />
</form>
<?php
if (isset($_POST['submit'])) {
if (isset($_FILES['upload1'])) {
$counter = count($_FILES['upload1']['name']);
for ($i = 0; $i < $counter; $i++) {
if (is_uploaded_file($_FILES['upload1']['tmp_name'][$i])) {
echo $_FILES['upload1']['tmp_name'][$i] . ' - ok <br>';
}
}
}
}
?>
Upvotes: 1
Reputation: 839
I would look at this location for further information on how to properly handle this case: http://www.php.net/manual/en/features.file-upload.multiple.php
Upvotes: 1