1 (edited by montana 2016-07-03 22:34:35)

Topic: Transmission with submit button

Hello everyone,

I would like to send all files with the submit-button. The upload is working fine, but the transmission with the submit button is not working properly. When I will send the form, the files are uploaded but the transmission is not going to dump.php. I need to select the button again to get the transmission to dump.php.

Iā€™m using this code with simple numeric array as example:

<form id="form" method="post" action="dump.php" enctype="multipart/form-data">
<?php 
    $num = array('1','2','3');
    foreach ($num as $upid) {
?>    
    <div id="uploader<?php echo $upid;?>">
        <p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
    </div>
    <input type="text" name="text<?php echo $upid;?>" value="<?php echo $upid;?>">
    <input type="hidden" name="frageid" value="2">


<script type="text/javascript">
$(function() {
    // Setup html5 version
    var uploader<?php echo $upid;?>  = $("#uploader<?php echo $upid;?>").plupload({
        // General settings
        runtimes : 'html5,html4',
        url : 'upload.php?frageid=2',
        rename : true,
        filters : {
            // Maximum file size
            max_file_size : '10mb',
            // Specify what files to browse for
            mime_types: [
                {title : "Image files", extensions : "jpg,gif,png"},
                {title : "Zip files", extensions : "zip"}
            ]
        },
        // Resize images on clientside if we can
        resize : {width : 320, height : 240, quality : 90},
        // Sort files
        sortable: true,
        views: {
            list: true,
            thumbs: true, // Show thumbs
            active: 'thumbs'
        }
    });
    // Handle the case when form was submitted before uploading has finished
    $('#form').submit(function(e) {
        // Files in queue upload them first
        if (uploader<?php echo $upid;?>.plupload('getFiles').length > 0) {
            // When all files are uploaded submit form
            uploader<?php echo $upid;?>.on('complete', function() {
                $('#form')[<?php echo $upid;?>].submit();
            });
            uploader<?php echo $upid;?>.plupload('start');
            return false; // Keep the form from submitting
        }
    });
});
</script>
<?php 
     }
?>
    <input type="submit" value="Send" />
</form>

Thanks for help