pedrorvidal

VIEW upload_form_v

Jun 14th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.03 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>jQuery Uploadify Demo</title>
  6. <script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  7. <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/uploadify/uploadify.css" />
  8. <script type="text/javascript" language="javascript" src="<?php echo base_url();?>assets/uploadify/swfobject.js"></script>
  9. <script type="text/javascript" language="javascript" src="<?php echo base_url();?>assets/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
  10. <?php
  11. /*$uploadpath = "";
  12. $uploadpath = str_ireplace($_SERVER['DOCUMENT_ROOT'],"",realpath($_SERVER['SCRIPT_FILENAME']));
  13. $uploadpath = str_ireplace("index.php","",$uploadpath);
  14. echo $uploadpath;*/
  15. ?>
  16. <script type="text/javascript" language="javascript">
  17.     $(document).ready(function(){
  18.                                    
  19.         $("#upload").uploadify({
  20.                 uploader: './assets/uploadify/uploadify.swf',
  21.                 script: './assets/uploadify/uploadify.php',
  22.                 cancelImg: './assets/uploadify/cancel.png',
  23.                 folder: './uploads/',
  24.                 scriptAccess: 'always',
  25.                 multi: true,
  26.                 'onError' : function (a, b, c, d) {
  27.                      if (d.status == 404)
  28.                         alert('Could not find upload script.');
  29.                      else if (d.type === "HTTP")
  30.                         alert('error '+d.type+": "+d.status);
  31.                      else if (d.type ==="File Size")
  32.                         alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
  33.                      else
  34.                         alert('error '+d.type+": "+d.text);
  35.                     },
  36.                 'onComplete'   : function (event, queueID, fileObj, response, data) {
  37.                                     //Post response back to controller
  38.                                     $.post('<?php echo site_url('upload/lista_enviados');?>',
  39.                                     {filearray: response},
  40.                                     function(info){
  41.                                         $("#target").append(info);  //Add response returned by controller                                                                        
  42.                                     });                                        
  43.                 }
  44.         });            
  45.     });
  46. </script>
  47. </head>
  48. <body>
  49. <h1>Uploadify Example</h1>
  50.     <?php echo form_open_multipart('upload/index');?>
  51.     <p>
  52.         <label for="Filedata">Choose a File</label><br/>
  53.         <?php echo form_upload(array('name' => 'Filedata', 'id' => 'upload'));?>
  54.         <a href="javascript:$('#upload').uploadifyUpload();">Upload File(s)</a>
  55.     </p>
  56.     <?php echo form_close();?>
  57.     <div id="target"> </div>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment