0

上传多个文件并保存它们不是问题。但我想把那些上传的文件显示在同一页面上

$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++;
    }
}

想要获取这些图像位置并定义它们,以便它们可以在页面下方进一步显示。

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

然后在后面的脚本:

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

谢谢你。

4

1 回答 1

0

知道了!试错...

$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++;
}
于 2013-05-11T16:47:21.810 回答