Skip to content

Instantly share code, notes, and snippets.

@thedineshj
Last active November 28, 2018 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedineshj/619fbbe86f969ea9997136923dc09805 to your computer and use it in GitHub Desktop.
Save thedineshj/619fbbe86f969ea9997136923dc09805 to your computer and use it in GitHub Desktop.
PHP - How to count number of uploaded files ?
<?php
if(isset($_POST['submit'])){
function countUploadedFiles($name){
/*
if a user submits the form
with out selecting any files
*/
if($_FILES[$name]['size'][0]==0){
echo "0 FILES UPLOADED";
return;
}
$filesCount=count($_FILES[$name]['tmp_name']);
echo "{$filesCount} FILES UPLOADED";
return;
}
countUploadedFiles("pictures");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment