0

我试图获取所有这些字段,它们都不是必需的,只是发布的内容存储一个带有车辆信息(这个正在工作)存储第二个带有车辆发布的图片(不工作,不知道如何)然后发送两个数组在一个add_car($vehicleinfo, &veihiclepictures)函数中, move_uploaded_file将调用一个文件并将文件实际放入文件夹中,并将地址放入 mysql

谁能帮我实现这一点,我完全迷路了

    <div class="addacar">
        <h3>Add a Car</h3>

    <form action="" method="post" enctype="multipart/form-data">
        <div class="one"><ul>

            <li>
                Year:<br>
                <input type="text" name="year">
            </li>
            <li>
                Make:<br>
                <input type="text" name="make">
            </li>
            <li>
                Model:<br>
                <input type="text" name="model">
            </li>
            <li>
                Engine:<br>
                <input type="text" name="engine">
            </li>
            <li>
                Sound System:<br>
                <input type="text" name="sound_system">
            </li>
            <li>
                Mileage:<br>
                <input type="text" name="mileage">
            </li>
            </ul>
        </div>
        <div class="two">
        <ul>
            <li>
                PRICE:<br>
                <input type="text" name="att1">
            </li>
            <li>
                Attribute 2:<br>
                <input type="text" name="att2">
            </li>
            <li>
                Attribute 3:<br>
                <input type="text" name="att3">
            </li>
            <li>
                Attribute 4:<br>
                <input type="text" name="att4">
            </li>
            <li>
                Attribute 5:<br>
                <input type="text" name="att5">
            </li>
            <li>
                Attribute 6:<br>
                <input type="text" name="att6">
            </li>
        </div>
        <div class="four">
            <li>
                Attribute 7:<br>
                <input type="text" name="att7">
            </li>
            <li>
                Attribute 8:<br>
                <input type="text" name="att8">
            </li>
            <li>
                Attribute 9:<br>
                <input type="text" name="att9">
            </li>
                <li>
                Attribute 10:<br>
                <input type="text" name="att10">
            </li>
            <li>
                Attribute 11:<br>
                <input type="text" name="att11">
            </li>


            </ul>
        </div>
        <div class="three">
        <ul>
            <li>Picture 1<input type="file" name="picture"></li>
            <li>Picture 2<input type="file" name="picture2"></li>
            <li>Picture 3<input type="file" name="picture3"></li>
            <li>Picture 4<input type="file" name="picture4"></li>
            <li>Picture 5<input type="file" name="picture5"></li>
            <li>Picture 6<input type="file" name="picture6"></li>
            <li>Picture 7<input type="file" name="picture7"></li>
            <li>Picture 8<input type="file" name="picture8"></li>
            <li>Picture 9<input type="file" name="picture9"></li>
            <li>Picture10<input type="file" name="picture10"></li>
            <li>Picture11<input type="file" name="picture11"></li>
            <li>Picture12<input type="file" name="picture12"></li>

        </ul>

    </div>
    <li><input type="submit"></li>
    </form>
        <div id="clear"></div>






 <?php
    if (isset($_POST) === true && isset($_FILES) === true)
    {

                    $vehicleinfo = array
                    (
                    'year'          => $_POST['year'],
                    'make'          => $_POST['make'],
                    'model'         => $_POST['model'],
                    'engine'        => $_POST['engine'],
                    'sound_system'  => $_POST['sound_system'],
                    'mileage'       => $_POST['mileage'],
                    'att1'          => $_POST['att1'],
                    'att2'          => $_POST['att2'],
                    'att3'          => $_POST['att3'],
                    'att4'          => $_POST['att4'],
                    'att5'          => $_POST['att5'],
                    'att6'          => $_POST['att6'],
                    'att7'          => $_POST['att7'],
                    'att8'          => $_POST['att8'],
                    'att9'          => $_POST['att9'],
                    'att10'         => $_POST['att10'],
                    'att11'         => $_POST['att11'],
                    'att12'         => $_POST['att12']);
                    $vehiclepictures = array (
                    'picture1'          => $_FILES['picture1'],
                    'picture2'          => $_FILES['picture2'],
                    'picture3'          => $_FILES['picture3'],
                    'picture4'          => $_FILES['picture4'],
                    'picture5'          => $_FILES['picture5'],
                    'picture6'          => $_FILES['picture6'],
                    'picture7'          => $_FILES['picture7'],
                    'picture8'          => $_FILES['picture8'],
                    'picture9'          => $_FILES['picture9'],
                    'picture10'         => $_FILES['picture10'],
                    'picture11'         => $_FILES['picture11'],
                    'picture12'         => $_FILES['picture12']

                    );
                    //add_car($vehicleinfo);
                    //header('Location: admin.php?success');
                    //exit();
                    print_r($vehicleinfo);
                    print_r($vehiclepictures);

    }
4

1 回答 1

0

首先,给你的提交按钮起一个名字,比如

<input name="submit" type="submit">

然后改变

if (isset($_POST) === true && isset($_FILES) === true)

if( isset( $_POST['submit'] ) )
{
    // ...
}

另请注意,您有

'att12' => $_POST['att12']);

但你没有12th输入,相反,你的最后一个input

<input type="text" name="att11">

所以,你应该添加另一个

<input type="text" name="att12">

最后,我不知道您要做什么,但对我来说看起来并不好。

于 2013-06-25T05:06:24.743 回答