You should check for errors first and report them to know what happened:
$file_err = $_FILES["img_files"]["error"][$i];
if($file_err != UPLOAD_ERR_OK){
$msg .= "File upload failed. Code " . $_FILES["img_files"]["error"][$i];
}
See also
PHP: Handling file uploads - Manual[
^].
If
move_uploaded_file()
fails even when there was no upload error a warning is issued. Because you did not got such warning, it seems that the file upload was not successful.
Otherwise check the destination file name:
Does the directory exist, has the script (account running the web server) write access to the directory, and is
$filename
a valid file name (does not contain reserved characters)?
Note also that
$folderName
must have a trailing slash when used here:
$filepath = $folderName . $filename;