I need to upload multiple files per request from my Android application to an apache webserver. I am on a Windows 10 computer and used XAMPP to set up the webserver.
When I upload a single file, everything works as intended. But when posting multiple fails they appear in the C:\xampp\tmp Folder, but then don't get moved.
This is how the $_FILES array looks like
<?php $_FILES = array (
'uploaded_file1' =>
array (
'name' => 'data1.csv',
'type' => 'text/csv',
'tmp_name' => 'C:\\xampp\\tmp\\phpA9A6.tmp',
'error' => 0,
'size' => 7991,
),
'uploaded_file2' =>
array (
'name' => 'data2.csv',
'type' => 'text/csv',
'tmp_name' => 'C:\\xampp\\tmp\\phpA9A7.tmp',
'error' => 0,
'size' => 24906727,
),
'uploaded_file3' =>
array (
'name' => 'data3.csv',
'type' => 'text/csv',
'tmp_name' => 'C:\\xampp\\tmp\\phpB244.tmp',
'error' => 0,
'size' => 12342379,
),
);
And this is the script I am trying to move them with
<?php
$move = "images/";
foreach ($_FILES['uploaded_file']['tmp_name'] as $key => $value)
{
$tmp_name = $_FILES['uploaded_file']['tmp_name'][$key];
$name = $move.basename($_FILES['uploaded_file']['name'][$key]);
move_uploaded_file($tmp_name, $name);
}
?>
I think it has to do with the name of the uploaded files, but when I try to set the name of each file to uploaded_file, the $_FILES array looks like this
<?php $_FILES = array (
'uploaded_file' =>
array (
'name' => 'data3.csv',
'type' => 'text/csv',
'tmp_name' => 'C:\\xampp\\tmp\\phpEF74.tmp',
'error' => 0,
'size' => 12342379,
),
);
I am not really experienced with HTTP and PHP so this is probably a trivial issue, but even with several different versions of the PHP script I cannot figure this out. Any help is greatly appreciated.
EDIT: The target directory C:\xampp\htdocs\images exists and I have adjusted the maximum upload and POST file size, but as I said only the moving the files is the issue.