I have the following code that uploads multiple files:
<?php
if(isset($_FILES['files'])){
$errors = array();
foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name){
$file_name = $key.$_FILES['files']['name'][$key];
$file_size = $_FILES['files']['size'][$key];
$file_tmp = $_FILES['files']['tmp_name'][$key];
$file_type = $_FILES['files']['type'][$key];
$file_parts = pathinfo($file_name);
$extensions = array("jpeg","jpg","png");
if(in_array ($file_parts['extension'],$extensions)){
//renomea o arquivo
$file_parts = ".".$file_parts['extension'];
$file_name = time().uniqid(md5()).$file_parts;
if($file_size > 2097152){
$errors[] = 'Tamanho do arquivo de ser menor que 2MB';
}//if($file_size > 2097152){
if(empty($errors)==true){
move_uploaded_file($file_tmp, "user_data/".$file_name);
}else{
print_r($errors);
}//if(empty($errors)==true){
}else{
$errors [] = 'Extensão não permitida';
}//if(in_array ($file_parts['extension'],$extensions))
if(empty($errors)){
print_r("<br/>".$file_name."<br/>");
echo "Sucesso";
}//if(empty($errors))
}//foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name)
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Upload</title>
</head>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="files[]" multiple>
<input type="submit" value="Enviar">
</form>
</body>
</html>
He is uploading the files normally and renaming, they are all in the file and renamed, but he has the following error when uploading:
Warning: md5 () expects at least 1 parameter, 0 given in C: \ xampp \ htdocs \ upload \ index.php on line 17
147293915357cb449171b91.jpg
Success
Warning: md5 () expects at least 1 parameter, 0 given in C: \ xampp \ htdocs \ upload \ index.php on line 17
147293915357cb449171f7a.jpg
Success
Warning: md5 () expects at least 1 parameter, 0 given in C: \ xampp \ htdocs \ upload \ index.php on line 17
147293915357cb449172362.jpg
Success
Does anyone have an idea of what it can be?