<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>
As you might have guessed from the code, i am uploading multiple files all the fields are
<input name="pictures[]" type="file" id="pictures[]" />
Now, my php code uploads the files names exactly as they are.
I am soon putting a variable in there called id, and what i need is for the uploaded files to be renamed so it is first the id,an underscore, then a number, ranging from 0 to 11 (i have 11 fields)
A sample of the name would look like
0_0.jpg
0_1.jpg
0_2.jpg
0_3.jpg
ect...
Is it possible to do this without using the rename function, or what would be the easyest way to achive this?
Thank you for your time
~Gabor