2

我有PHP上传脚本,没问题,但是如果我使用jquery mobile,上传文件不起作用。

这是我的脚本

    <!DOCTYPE html> 
    <html> 
        <head> 
        <title>Security</title> 
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <link rel="stylesheet" href="jqm/jquery.mobile-1.1.0.min.css" />
        <!--script src="jqm/jquery-1.7.1.min.js"></script>        //if I Open this line, the upload script don't work.
        <script src="jqm/jquery.mobile-1.1.0.min.js"></script-->  //if I Open this line, the upload script don't work.

        </head> 
    <body> 

    <?php

     include "koneksi.php";

     if (isset($_POST[SAVE]))
     {

          $tglkirim    = $_POST[TGLKIRIM];
          $nopol       = $_POST[NOPOL];
          $jenis       = $_POST[JENIS];
          $namasupexp  = $_POST[NAMASUPEXP];
          $bkirim      = $_POST[BKIRIM];
          $kotatujuan  = $_POST[KOTATUJUAN];
          $jamm        = $_POST[JAMM];
          $jamk        = $_POST[JAMK];
          $namasopir   = $_POST[NAMASOPIR];
          $jkendaraan  = $_POST[JKENDARAAN];
          $sj          = $_POST[SJ];       
          $stnk        = $_POST[STNK];
          $sim         = $_POST[SIM];
          $lrem        = $_POST[LREM];
          $lkota       = $_POST[LKOTA];
          $lsign       = $_POST[LSIGN];
          $spion       = $_POST[SPION];
          $sabuk       = $_POST[SABUK];




          // $ukuran_gbr = GetImageSize($direktori);
          $lokasi_file = $_FILES['fupload']['tmp_name'];  //script for upload
          $nama_file   = $_FILES['fupload']['name'];      //script for upload
          $ukuran_file = $_FILES['fupload']['size'];      //script for upload  
          $tipe_file   = $_FILES['fupload']['type'];      //script for upload
          $direktori   = "fkendaraan/$nama_file";         //script for upload

          print_r($_POST);



             move_uploaded_file($lokasi_file,"$direktori"); //script for move upload file

             echo "Nama File   :<b>$nama_file</b> sukses di Upload<br>";
             echo "Ukuran File :<b>$ukuran_file</b> bytes<br>";  





          $sql="INSERT INTO tb_secure (tgl_kirim,
                                          nopol,
                                           jenis,
                                             namasupexp,
                                               bkirim,
                                                kota_tujuan,
                                                  jam_masuk,
                                                    jam_keluar,
                                                      nama_sopir,
                                                       jenis_kendaraan,
                                                         surat_jalan,
                                                           stnk,
                                                             sim,
                                                               lrem,
                                                                 lkota,
                                                                   lsign,
                                                                     spion,
                                                                       sabuk,
                                                                         nama_file,
                                                                           ukuran_file,
                                                                              direktori)                   
    VALUES('$tglkirim',
             '$nopol',
                '$jenis',
                   '$namasupexp',
                      '$bkirim',
                        '$kotatujuan',
                           '$jamm',
                             '$jamk',
                               '$namasopir',
                                 '$jkendaraan',
                                    '$sj',
                                      '$stnk',
                                        '$sim', 
                                          '$lrem',
                                            '$lkota',
                                              '$lsign',
                                                '$spion',
                                                   '$sabuk',
                                                     '$nama_file',
                                                       '$ukuran_file', 
                                                          '$direktori')";


         $sql2="INSERT INTO temp_gudang(nopol,tgl_kirim)VALUES('$nopol','$tglkirim')";                                                    

         $input=mysql_query($sql);
         $input2=mysql_query($sql2);



          if ($input && $input2)
          {
             echo "<strong>Data berhasil dimasukkan</strong>";
             //echo "<script language='javascript'>";
             //echo " alert('Data berhasil dimasukkan');";
            //echo " alert(print_r($_POST));";
             //echo "window.location='admin/index-admin.php';";
             //echo "</script>
          }
          else
          {
             echo "<strong>Data tidak berhasil dimasukkan, check ukuran gambar, yg diperbolehkan kurang dari 1.5 Mb </strong>";
          }


     } 
<?php 
 if (isset($_SESSION['username']))
 {

 ?>

<div data-role="page" class="type-interior" data-theme="b">
<div data-role="header">
        <!--h1>PT UNIMOS GRESIK</h1-->
        <h1>CHECKLIST APPS </h1>
        <h2>Security</h2>
    </div><!-- /header -->
 Anda Login Sebagai  <?php echo $_SESSION['username'];?> 
    <div data-role="content">   
<form action="satpam.php" enctype="multipart/form-data"  method="post">
    Tanggal Pengiriman
    <input type="text" name="TGLKIRIM" id="TGLKIRIM" value="<?php echo "$today";?>" />
    Nomor Kendaraan
    <input type="text" name="NOPOL" id="NOPOL" value=""  />
    Nama
    <select name="JENIS" id="switch-a" data-role="slider">
                          <option value="Suplier">Sup</option>
                          <option value="Expedisi">Exp</option>
    </select>     

   <select name="NAMASUPEXP" id="select-choice-a" data-native-menu="false">
     <option >Ekspedisi</option>
       <?php
        $sql="SELECT * FROM tb_exp_local";
        $hasil = mysql_query($sql);

        while($data=mysql_fetch_array($hasil))
         {
           echo "<option value=$data[nama_exp] width=300>$data[nama_exp]</option>";
         }
       ?>
    </select>
    <td colspan="3">Barang Yang Dikirim</td>
    <input type="text" name="BKIRIM" id="BKIRIM" value="">
    Kota Tujuan 
    <!--input type="text" name="KOTATUJUAN" id="KOTATUJUAN" value=""  /-->
    <select name="KOTATUJUAN" id="select-choice-a" data-native-menu="false">
     <option >Kota Tujuan</option>
       <?php
        $sql="SELECT * FROM tb_exp_local";
        $hasil = mysql_query($sql);

        while($data=mysql_fetch_array($hasil))
         {
           echo "<option value=$data[kota_tujuan]>$data[kota_tujuan]</option>";
         }
       ?>
    </select>
    Jam Masuk     
    <input type="text" name="JAMM" id="JAMM" value="<?php echo "$time";?>"/>
    Jam Keluar
    <input type="text" name="JAMK" id="JAMK" value=""  />
    Nama Pengemudi
    <input type="text" name="NAMASOPIR" id="NAMASOPIR" value=""  />
    Jenis Kendaraan
           <select name="JKENDARAAN" id="select-choice-a" data-native-menu="false">
                  <option>Jenis Kendaraan</option>
                  <option value="Pick Up">Pick Up</option>
                  <option value="Colt Diesel">Colt Diesel</option>
                  <option value="Fuso">Fuso</option>
                  <option value="Truck bak Tertutup">Truck bak Tertutup</option>
                  <option value="Container">Container</option>
            </select> 
      <table>      
      <tr>
         <td colspan="2">Surat Jalan</td><td><select name="SJ" id="switch-a" data-role="slider">
                          <option value="Ada">Ada</option>
                          <option value="Tidak">Tidak</option>
             </select></td>
        </tr>    
      <tr>
         <td colspan="2">Buku KIR & STNK</td>
         <td>
            <select name="STNK" id="STNK" data-role="slider">
            <option value="Ada">Ada</option>
            <option value="Tidak">Tidak</option>
            </select>
         </td>
      </tr>
      <tr>
         <td colspan="2">SIM</td> 
         <td> <select name="SIM" id="SIM" data-role="slider">
                          <option value="Ada">Ada</option>
                          <option value="Tidak">Tidak</option>
              </select>
         </td>           
      </tr>
      <tr>
         <td colspan="2">Lampu Rem</td>
         <td><select name="LREM" id="LREM" data-role="slider">
                          <option value="Oke">Oke</option>
                          <option value="Tidak">Tidak</option>
              </select>
         </td>          
      </tr>
      <tr>
         <td colspan="2">Lampu Kota</td>
         <td><select name="LKOTA" id="LKOTA" data-role="slider">
                          <option value="Oke">Oke</option>
                          <option value="Tidak">Tidak</option>
             </select>
         </td> 
      </tr>
      <tr>
         <td colspan="2">Lampu Sign</td>   
         <td> <select name="LSIGN" id="LSIGN" data-role="slider">
                          <option value="Oke">Oke</option>
                          <option value="Tidak">Tidak</option>
              </select>
         </td>       
      </tr>
      <tr>
        <td colspan="2">Kaca Spion</td>
        <td><select name="SPION" id="SPION" data-role="slider">
                          <option value="Oke">Oke</option>
                          <option value="Tidak">Tidak</option>
            </select></td>
      </tr>
      <tr>
        <td colspan="2">Sabuk Pengaman</td>
        <td><select name="SABUK" id="SABUK" data-role="slider">
                          <option value="Ada">Ada</option>
                          <option value="Tidak">Tidak</option>
            </select></td>
      </tr>
      </div><!-- /content -->
 </div><!-- /page -->

      <tr>
        <td colspan="2">Upload</td>
        <!--td><input type="file" name="fupload" /></td-->
        <td><input type="file" accept="image/*;capture=camera" name="fupload" id="file"></td>

      </tr>
      <tr>
        <td colspan="2" align="right"><input type="submit" name="SAVE" value="SAVE"></td>
      </tr> 
      <tr>
         <td colspan="2"><a href="logout.php" data-role="button" data-icon="home" onclick='logout()'>Log Out</a></td> 
       <?php
        echo "<script language='javascript'>";
        echo "function logout()";
        echo "{window.location.assign('logout.php');}";
        echo "</script>";
        ?>
      </tr>
      </table>
       </form>



<?php 
}
?>
</body>
</html>

为什么唯一上传脚本不起作用?插入数据等其他脚本工作正常。

任何人都可以帮助我吗?

4

1 回答 1

0

你确定你已经包含enctype在你的<form>声明中了吗?

<form action="" method="post" enctype="multipart/form-data">

于 2012-07-21T01:14:18.987 回答