Got this bit of code:
if ($_FILES["file1"]["error"] == 0) {
move_uploaded_file($_FILES["file1"]["tmp_name"], "path/".$_FILES["file1"]["name"]);
}
I would like to reuse it for more files being uploaded. Was thinking function with some params but it seems i can't get the vars correctly.
Ok fixed it like this:
function upload($file) {
$allowedExts = array("pdf, jpg, gif, png");
$extension = end(explode(".", $_FILES[$file]["name"]));
if (in_array($extension, $allowedExts)) && ($_FILES[$file]["error"] == 0) {
move_uploaded_file($_FILES[$file]["tmp_name"], "img/new/".$_FILES[$file]["name"]);
}
}
And calling via:
upload("file1");
Not sure about the $_FILES
loop...