Advertisement
GWibisono

multi upload ke db

May 19th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php  
  2.  
  3. include 'index2.php';
  4. include 'fungsi_editanq.php';
  5. $con = mysql_connect("localhost","root","");
  6. if (!$con) {
  7. die('Koneksi ke database gagal: ' . mysql_error());
  8. }
  9. mysql_select_db("uji1", $con);
  10. mysql_query("truncate table `tbberita`");
  11. mysql_query("truncate table `tbkeyword`");
  12. mysql_query("truncate table `tbstem`");
  13. mysql_query("truncate table `tbtoken`");
  14.  
  15.  
  16.  
  17. if(isset($_POST)){
  18.      $n=count($_FILES['userfile']['name']);
  19.      //print_r($_FILES);
  20.     for ($i=0; $i<=$n-1; $i++){
  21.         /*
  22.         $string = file_get_contents ($_FILES['userfile'.$i]['tmp_name']);    
  23.         stemming2($string);
  24.        
  25.         tidak dapat mengeksekusi fungsi stemming2,kenapa ya???
  26.         padahal sudah saya looping
  27.         */
  28.         //echo '<pre>';print_r($_FILES['userfile']['tmp_name'][$i]);
  29.         //echo '</pre>';
  30.         $string = file_get_contents ($_FILES['userfile']['tmp_name'][$i]);    
  31.         stemming2($string);
  32.        
  33.     }
  34.    
  35.      
  36. }
  37. ?>
  38. <html>
  39. <head>
  40.    <title>Multiple File Upload</title>
  41.    <script type="text/javascript">
  42.  
  43.    function show()
  44.         {
  45.             var n = document.myform.jumfile.value;
  46.             var i;
  47.             var string = "";
  48.  
  49.             for (i=0; i<=n-1; i++)
  50.             {
  51.                string = string + "Pilih File: <input name=\"userfile[]\" type='file'><br>";
  52.             }
  53.  
  54.             document.getElementById('selectfile').innerHTML = string;
  55.             document.myform.n.value = n;
  56.         }
  57.     </script>
  58. </head>
  59. <body>
  60. <?php
  61. echo "<form name='myform' enctype='multipart/form-data' method='POST'>
  62.        Pilih Jumlah File
  63.        <select name='jumfile' onchange='show()'>
  64.         <option >Pilih dari jumlah dibawah</option>
  65.            <option value='1'>1</option>
  66.            <option value='2'>2</option>
  67.            <option value='3'>3</option>
  68.            <option value='4'>4</option>
  69.            <option value='5'>5</option>
  70.            <option value='6'>6</option>
  71.        </select>
  72.        <br><br>
  73.        <input type='hidden' name='MAX_FILE_SIZE' value='20000000' />
  74.        <div id='selectfile'>
  75.        </div>
  76.    <br>
  77.    <input type='hidden' name='n'  value='1' />
  78.   <INPUT TYPE=SUBMIT VALUE='Stem!' name ='submit'>
  79.    </form>";
  80.     ?>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement