Loading ...
Sorry, an error occurred while loading the content.
 

Re: Using Connection manager and file upload

Expand Messages
  • Lucas Smith
    ... onClick= postForm( controleprincipal.php?controle=controlerecept&action=chargerFichier ,document.getElementById( upload_form )); / ... Jerome, You re not
    Message 1 of 2 , Aug 29, 2008
      --- In ydn-javascript@yahoogroups.com, "jerome" <jeromekbe@...> wrote:
      >
      > Hello all, i have a problem with my file upload (with my own crafted
      > progress bar) in yui 2.5.2
      >
      > I have this html code :
      >
      > <form enctype="multipart/form-data" id="upload_form"
      > name="upload_form" action="" method="POST">
      > <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key"
      > value="<?php echo uniqid()?>"/>
      > <input type="file" id="test_file" name="test_file"/><br/>
      > <input id="submit" name="submit" type="button" value="Chargement"
      >
      onClick="postForm('controleprincipal.php?controle=controlerecept&action=chargerFichier',document.getElementById('upload_form'));"/>
      > </form>
      >
      >
      > my postForm function is this :
      >
      > function postForm(target,formName){
      > alert("entree dans la fonction postForm");
      > elmtForm = formName;
      > alert(elmtForm);
      > YAHOO.util.Connect.setForm(elmtForm,true);
      > YAHOO.log("fct setForme :"+YAHOO.util.Connect.setForm(elmtForm,true));
      > YAHOO.util.Connect.asyncRequest('POST',target,callback);
      > alert("avant ke je d├ęclare le panel");
      > progress_win = new YAHOO.widget.Panel("progress_win", {
      > width:"420px", fixedcenter:false, underlay:"shadow", close:false,
      > draggable:true, modal:true,
      > effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.3} } );
      > progress_win.setHeader("Chargement de
      > "+document.getElementById('test_file').value+" ...");
      > progress_win.setBody('<div style="height: 1em; width: 400px;
      > border:1px solid #000;"> <div id="pbar" style="background: #99e;
      > height: 98%; width:0%; float:left;"> </div> <div id="ppct"
      > style="height: 90%; position: absolute; margin: 1 0 0
      > 185;">0%</div></div><div id="ptxt" style="margin: 3 0 0 5">0 of 0
      > octets</div>');
      > progress_win.render(document.body);
      > update_progress();
      > }
      >
      >
      > But the setForm function will only return 'undefined' :/
      >
      > what do i do wrong (and it work with a previous release of yui)?
      >

      Jerome,

      You're not doing anything wrong. setForm returns silently in the case
      of file upload forms. For file uploads setForm/asyncRequest creates
      an iframe to handle the transaction, and as such doesn't need to parse
      through the form fields to assemble the XHR post data.

      Also, you might want to attach the postForm function outside the
      markup, and call YAHOO.util.Event.preventDefault(e) from inside.
      Otherwise the form will be submitted once thru YUI async, and once via
      normal form submission.

      Hope this helps,
      Luke
    Your message has been successfully submitted and would be delivered to recipients shortly.