Hi all,
On my PHP form i have 5 upload fields each with a unique name.
This is my first attempt at creating a form which uploads multiple images so all I would like is some advice on if this approach is way off what it should be and if it is, maybe a short explanation of how it should be done?
For each upload field i have this PHP code:
$imgA = $_FILES['uploadimageA']['tmp_name'];
if (!empty($_FILES['uploadimageA']['tmp_name'])) {
if (move_uploaded_file($imgA, $targetpath . basename( $_FILES['uploadimageA']['name']))) {
$chmodpath = $targetpath . basename( $_FILES['uploadimageA']['name']);
chmod ("$chmodpath",0644);
$imageisuploaded = true;
} else {
// error message would be here...
}
}
Where the 'uploadimageA' references the letter A, I would change to be 'uploadimageB', 'uploadimageC' and so on.
Therefore the same code is duplicated down my page 5 times but each field has a different letter making the name unique.
Is this ridiculously poor?
By the way, it uploads the images fine.
Thanks in advance.