提交具有多种文件类型输入的PHP表单

时间:2019-05-03 11:22:02

标签: php file-upload yii multiple-files

我有一个具有多种输入类型(例如文本,文件等)的PHP表单。当我尝试使用单一文件类型输入提交表单时,该表单将正确提交,但是当我在表单中添加另一个文件类型输入标记并提交时然后执行就被卡住了我的代码在下面。

<style>
.contentpanel .col-sm-12 {
border-bottom: 1px solid #000;
padding: 10px;
}
</style>

<form method="post" action="<?php echo Helpers::yiiparam("siteUrl") . 'myfile.php'; ?>" enctype="multipart/form-data" id="tempFileUpload">
<!-- <div class="col-sm-12">
    <div class="col-sm-3">
        <label>Enter Name</label>
    </div>
    <div class="col-sm-9">
        <input type="text" class="form-input" name="userfname" id="username">
    </div>
</div>
<div class="col-sm-12">
    <div class="col-sm-3">
        <label>Enter Url</label>
    </div>
    <div class="col-sm-9">
        <input type="text" class="form-input" name="weburl" id="weburl">
    </div>
</div>
<div class="col-sm-12">
    <div class="col-sm-3">
        <label>Select Image 1</label>
    </div>
    <div class="col-sm-9">
        <input type="file" class="form-input" name="image1" id="image1">
    </div>
</div>
<div class="col-sm-12">
    <div class="col-sm-3">
        <label>Video</label>
    </div>
    <div class="col-sm-9">
        <input type="file" class="form-input" name="video1" id="video1">
    </div>
</div> -->
<div class="col-sm-12">
    <div class="col-sm-3">
        <label>Custom Button</label>
    </div>
    <div class="col-sm-9">
        <input type="text" class="form-input" name="custom_button_txt" id="custom_button_txt">
        <input type="file" class="form-input" name="custom_button[]" id="custom_button">
    </div>
</div>
 <div class="col-sm-12">
    <div class="col-sm-3">
        <label>Image Gallery</label>
    </div>
    <div class="col-sm-9">
        <input type="file" class="form-input" name="custom_button[]" id="galleryimg1">
    </div>
    <!-- <div class="col-sm-9">
        <input type="file" multiple="multiple" class="form-input" name="images2" id="galleryimg2">
    </div> -->
</div> 
<div class="col-sm-12">
    <div class="col-sm-3">
        <label>Social Media Link</label>
    </div>
    <div class="col-sm-9">
        <input type="text" class="form-input" name="social_media_title" id="social_media_title" placeholder="Enter Title"><br/>
        <input type="text" class="form-input" name="social_media_link" id="social_media_link" placeholder="Enter Url">
    </div>
</div>
<div class="col-sm-12">
    <input class="btn btn-primary action-button" name="next" type="submit" value="Save & Next" id="stepBtnSection" />
</div>

动作文件代码如下

<?php
echo phpinfo();
exit;
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo '<pre>';
print_r($_POST);
print_r($_FILES);
die;
?>

0 个答案:

没有答案