duanmo6937 2015-01-27 18:13
浏览 8

move_uploaded_file用于不同的输入文件

the method I have is I create three input files which will be posted to three different column in database table.

Heres my parameter:

$additional_comments=$_POST['additional_comments']; 
$image_one = $_FILES['image_one']['type'];
$image_two = $_FILES['image_two']['type'];
$image_three = $_FILES['image_three']['type'];

    if($image=="image/jpeg" || $image=="image/jpg" || $image=="image/gif" || $image=="image/png") 
        {           
            $gambar_satu        = $foldername . basename($_FILES['image_one']['name']);  
            $gambar_dua         = $foldername . basename($_FILES['image_two']['name']);  
            $gambar_tiga        = $foldername . basename($_FILES['image_three']['name']);  

                if  (   move_uploaded_file 
                            ($_FILES['image']['tmp_name'], $gambar_satu) 
                            ($_FILES['image']['tmp_name'], $gambar_dua) 
                            ($_FILES['image']['tmp_name'], $gambar_tiga) 
                    ) 

                    {
                        $stmt = $mysqli->prepare
                            ("INSERT INTO table...

In the if (move_uploaded_file... I am trying to insert three paramater there which they are $gambar_satu, $gambar_dua, $gambar_tiga.

My question is how is the correct way to do this? Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongpu2727 2015-01-27 18:19
    关注

    Quoting directly from the php website

    <?php
    $uploads_dir = '/uploads';
    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, "$uploads_dir/$name");
     }
    }
    ?>
    

    Hope it helps!

    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源