Welcome Guest, Not a member yet? Register   Sign In
form with large files and input
#1

HI , sorry for english , i must send one or several file (large file) and input  to save file and store input (text and textarea to db ) , i see plupload but i don't see how send input , wath can i use for this ?
.
Reply
#2

Check the docs.
Reply
#3

(12-13-2020, 02:24 AM)sammyskills Wrote: Check the docs.

This is my code :
view :


Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<title>Plupload - jQuery UI Widget</title>

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="<?=base_url() ?>/assets/js/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>

<!-- production -->
<script type="text/javascript" src="<?=base_url() ?>/assets/js/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="<?=base_url() ?>/assets/js/plupload/jquery.ui.plupload/jquery.ui.plupload.js"></script>

<!-- debug
<script type="text/javascript" src="../../js/moxie.js"></script>
<script type="text/javascript" src="../../js/plupload.dev.js"></script>
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
-->

</head>
<body style="font: 13px Verdana; background: #eee; color: #333">

<h1>jQuery UI Widget</h1>

<p>You can see this example with different themes on the <a href="http://plupload.com/example_jquery_ui.php">www.plupload.com</a> website.</p>

<form id="form" method="post" action="<?=base_url() ?>/ajax_call/upload_file_esami" enctype="multipart/form-data">
  <input type="text" id="nome" name="nome">
  <input type="text" id="cognome" name="cognome">
  <div id="uploader">
    <p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
  </div>
  <br />
  <input type="submit" name="invia">
</form>

<script type="text/javascript">
// Initialize the widget when the DOM is ready
$(function() {
  $("#uploader").plupload({
    // General settings
    runtimes : 'html5,flash,silverlight,html4',
    url : "<?=base_url() ?>/ajax_call/upload_file_esami",

    // User can upload no more then 20 files in one go (sets multiple_queues to false)
    max_file_count: 20,
   
    chunk_size: '1mb',

    // Resize images on clientside if we can
    resize : {
      width : 200,
      height : 200,
      quality : 90,
      crop: true // crop to exact dimensions
    },
   
    filters : {
      // Maximum file size
      max_file_size : '1000mb',
      // Specify what files to browse for
      mime_types: [
        {title : "Image files", extensions : "jpg,gif,png"},
        {title : "Zip files", extensions : "zip"}
      ]
    },

    // Rename files by clicking on their titles
    rename: true,
   
    // Sort files
    sortable: true,

    // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
    dragdrop: true,

    // Views to activate
    views: {
      list: true,
      thumbs: true, // Show thumbs
      active: 'thumbs'
    },
    multipart_params : {
        "name1" : $('#nome').val(),
        "name2" : $('#cognome').val()
    },

    // Flash settings
    flash_swf_url : '../../js/Moxie.swf',

    // Silverlight settings
    silverlight_xap_url : '../../js/Moxie.xap'
  });


  // Handle the case when form was submitted before uploading has finished
  $('#form').submit(function(e) {
    // Files in queue upload them first
    if ($('#uploader').plupload('getFiles').length > 0) {
     
      $('#uploader').plupload('start');
      // When all files are uploaded submit form
      $('#uploader').on('complete', function() {
        $('#form')[0].submit();
        console.log($('#nome').val());
      });

     
    } else {
      alert("You must have at least one file in the queue.");
    }
    return false; // Keep the form from submitting
  });
});
</script>
</body>
</html>

controller :


PHP Code:
public function upload_file_esami()
     {
         
//recupero le informazioni del file
                $img $this->request->getFile('file');

                //DEBUG
                
                print_r
($_POST);

                if ($img) {
                    $img->getName();
                }else{

                    echo 'nessun file';
                }
                //echo $img->getName();

                exit();
                
                
//echo APPPATH . 'assets/images/foto_esami';

                //exit();
/*
                //lo trasferisco nella cartella uploads
                if($img->move(FCPATH . '/assets/upload/upload_esami')){

                    $post = $this->request->getPost();
                    log_message('debug',$post['name1']);
                    log_message('debug',$post['name2']);
                    return true;
                }*/
     


if use the start upload button (changing controller code)  (after i want remove it) file are uploaded into the folder correctly but no text are sended.
if i use the invia (submit button of form) text are sended but not file .
what are my errors ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB