php foreach上传文件定义变量

Not a problem to upload multiple files and save them. But I would like to take those uploaded files and display them on the same page

$ebtitle2 = substr(preg_replace("/[^A-Za-z0-9]/", "", $ebtitle), 0, 8);
$upload_folder = '../ebay/images/'. $Date.'-'.$ebtitle2."/";
mkdir("$upload_folder");
$z = 0;
foreach ($_FILES["uploaded_file"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {

    $tmp_name = $_FILES["uploaded_file"]["tmp_name"][$key];
    $uname = $_FILES["uploaded_file"]["name"][$key];
    $folderandname = $upload_folder.$z.$ebtitle2.$uname;
    move_uploaded_file($tmp_name, $folderandname);
    $z++;
    }
}

Would like to take these image locations and define them so they can be displayed further on down the page.

$x = $z;
while($z > 0) {
    $imgURL['$z'] = $folderandname[];
    $z -1;
}

Then later on down the script:

<?php while($x > 0) { ?>
<img src='<?php $imageURL[]; ?>'>
<?php $x -1;} ?>

Thank you.

Got it! Trial and error...

$ebtitle2 = substr(preg_replace("/[^A-Za-z0-9]/", "", $ebtitle), 0, 8);
$upload_folder = '../ebay/images/'. $Date.'-'.$ebtitle2."/";
mkdir("$upload_folder");
$z = 0;
foreach ($_FILES["uploaded_file"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["uploaded_file"]["tmp_name"][$key];
        $uname = $_FILES["uploaded_file"]["name"][$key];
        $folderandname = $upload_folder.$z.$ebtitle2.$uname;
        move_uploaded_file($tmp_name, $folderandname);
        $imgURL[] = $Date.'-'.$ebtitle2."/".$z.$ebtitle2.$uname;
        $z++;
    }
}

$x = 0;
while($z > 0) {
    echo "<img src='https://itdsi.com/ebay/images/".$imgURL[$x]."'>";
    $z--;
    $x++;
}