Tidak Bisa UPLOAD file ke Server

Eko Setiawan · Sep 4, 2012
Selamat Siang, saya mau bertanya untuk semuanya.

saya membuat form isian menggunakan php, form isian tersebut terdiri dari isian teks dan upload file, nah saat user mengisi isian dan mengupload file. isian tersebut akan masuk ke database, file tersebut masuk ke server dan isian + file tersebut masuk juga ke email.

saya berhasil menjalankan program saya ini TETAPI OffLine, Jika dionlinekan File tidak berhasil di Upload ke server dan tidak berhasil di attach ke email.

berikut ini file form isian yang saya berinama isian.php
<form name="input_data" action="hasil.php" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="5" cellspacing="0" width="700px">
    <tbody>
        <tr>
            <td colspan="3">A.	DATA PRIBADI PEMOHON</td>
		</tr>
            
        <tr>
            <td>Nama Lengkap</td>
            <td></td>
            <td>: <input width="200px"; type="text" name="nama" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>No. KTP</td>
            <td></td>
            <td >: <input type="text" name="noktp"  required="required" size="50" /></td>
        </tr>

        <tr>
            <td>Jenis Kelamin</td>
            <td></td>
            <td><label> <input type="radio" name="JK" value="perempuan" /> <?if($_SESSION['JK']=='perempuan'){echo "checked";}?> Perempuan</label><br />
            <label> <input type="radio" name="JK" value="laki" /> <?if($_SESSION['JK']=='laki'){echo "checked";}?> Laki-Laki</label><br />  </td>
        </tr>
                       
        <tr>
	        <td>Alamat Rumah</td>
            <td></td>
            <td>: <textarea name="almrm" id ="almrm" cols="50" rows="5" /> </textarea> </td>
        </tr>
        <tr>
            
            <td>&nbsp;</td>
            <td>RT/RW</td>
            
            <td>: <input type="text" name="rt" required="required" size="50" /></td>
            
            
        </tr>
        <tr>
        	<td>&nbsp;</td>
            <td>Kelurahan</td>
            <td>: <input type="text" name="kel"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kecamatan</td>
            <td>: <input type="text" name="kec"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kodya/Kab</td>

            <td>: <input type="text" name="kab"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kode Post</td>

            <td>: <input type="text" name="kdp"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Telp/Fax</td>
            <td></td>
            <td>: <input type="text" name="telp" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>HP</td>
            <td></td>
            <td>: <input type="text" name="hp" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Email</td>
            <td></td>
            <td>: <input type="text" width="300px" name="email" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Pendidikan Terakhir</td>
            <td></td>
            <td>: <input type="text" name="pend" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Pekerjaan</td>
            <td></td>
            <td>: <input type="text" name="kerja" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Jabatan</td>
            <td></td>
            <td>: <input type="text" name="jabat" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Alamat Kantor</td>
            <td></td>
            <td>: <input type="text" name="almka" required="required" size="50" /></td>
        </tr>
        <tr>
            <td>Telp. Kantor</td>
            <td></td>
            <td>: <input type="text" name="telpkantor" required="required" size="50" /></td>
        </tr>
		<tr>
            <td colspan="3">&nbsp;</td>
		</tr>
        
        
        
        
		<tr>
            <td colspan="3">B.	DATA USULAN LOKASI</td>
		</tr>                                                                                                

        <tr>


            <td>Alamat</td>
            <td></td>
            <td>: <textarea name="almusulan" id ="almusulan" cols="50" rows="5" /> </textarea> </td>
        </tr>
        <tr>
            
            <td>&nbsp;</td>
            <td>RT/RW</td>
            
            <td>: <input type="text" name="rtusulan" required="required" size="50" /></td>
            
            
        </tr>
        <tr>
        	<td>&nbsp;</td>
            <td>Kelurahan</td>
            <td>: <input type="text" name="kelusulan"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kecamatan</td>
            <td>: <input type="text" name="kecusulan"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kodya/Kab</td>

            <td>: <input type="text" name="kabusulan"  required="required" size="50" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Kode Post</td>

            <td>: <input type="text" name="kdpusulan"  required="required" size="50" /></td>
        </tr>

        <tr>

            <td>Telepon Lokasi</td>
			            <td></td>	
            <td>: <input type="text" name="telplokasi"  required="required" size="50" /></td>
        </tr>        
        
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>

            <td>  &nbsp;&nbsp;Luas</td>
        </tr>
        
        <tr>
 			<td>&nbsp;</td>
            <td>Panjang</td>
            <td>: <input type="text" name="panjang"  required="required" size="40" /> Meter</td>
            
        </tr>

        <tr>
 			<td>&nbsp;</td>
            <td>Lebar</td>
            <td>: <input type="text" name="lebar"  required="required" size="40" /> Meter</td>
            
        </tr>        

        <tr>
 			<td>&nbsp;</td>
            <td>Jumlah Lantai</td>
            <td>: <input type="text" name="lantai"  required="required" size="40" /> Lantai</td>
            
        </tr>

        <tr>
            <td>Bentuk Lokasi</td>
            <td>&nbsp;</td>
            <td>:</td>
        </tr>
                       
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
            		<label><input type="radio" name="BLK" value="tanahkosong"  /><?if($_SESSION['BLK']=='tanahkosong'){echo "checked";}?> Tanah Kosong</label><br />
                    <label><input type="radio" name="BLK" value="ruko"  /><?if($_SESSION['BLK']=='ruko'){echo "checked";}?> Ruko</label><br />
					<label><input type="radio" name="BLK" value="rumah"  /><?if($_SESSION['BLK']=='rumah'){echo "checked";}?> Rumah</label><br /> </td>
        </tr>


        <tr>
            <td>Status Lokasi</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
                       
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
            		<label><input type="radio" name="SLK" value="sewa"  /><?if($_SESSION['SLK']=='sewa'){echo "checked";}?> Sewa</label><br />
                    <label><input type="radio" name="SLK" value="milikkeluarga"  /><?if($_SESSION['SLK']=='milikkeluarga'){echo "checked";}?> Milik Keluarga</label><br />
					<label><input type="radio" name="SLK" value="miliksendiri"  /><?if($_SESSION['SLK']=='miliksendiri'){echo "checked";}?> Milik Sendiri</label><br />
                    <label><input type="radio" name="SLK" value="milikperusahaan"  /><?if($_SESSION['SLK']=='milikperusahaan'){echo "checked";}?> Milik Perusahaan</label><br />
            </td>
        </tr>

        <tr>
            <td>Denah Lokasi</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
            		<label><input type="radio" name="DLK" value="ada"  /><?if($_SESSION['SLK']=='ada'){echo "checked";}?> Ada</label><br />
                    <label><input type="radio" name="DLK" value="tidakada"  /><?if($_SESSION['SLK']=='tidakada'){echo "checked";}?> Tidak Ada</label><br />

            </td>
        </tr>
        
		<tr>

            <td>File Denah Lokasi</td>
			            <td></td>	
            <td>: <input name="nama_file" type="file" id="nama_file" size="30" /></td>
        </tr>
        

		<tr>
            <td colspan="3">C.	MINAT TAKE OVER</td>
		</tr>                                                                                                


        <tr>
	        <td>&nbsp;</td>
            <td>Daerah yang Diminati</td>
            
            <td>: <textarea name="daerah" id ="daerah" cols="50" rows="5" /> </textarea> </td>
        </tr>        

        <tr>
	        <td>&nbsp;</td>
            <td>Estimasi Budjet</td>
            
            <td>: <input type="text" name="budjet1"  required="required" /> &nbsp; s/d &nbsp; Rp <input type="text" name="budjet2"/></td>
            
        </tr>        

        <tr>
	        <td>&nbsp;</td>
            <td></td>
            
            <td>&nbsp;&nbsp;<input type="checkbox" name="cek"  required="required" /> &nbsp; Dengan ini saya menyatakan bahwa semua data tersebut benar.</td>
            
        </tr>
                               
        <tr>
            <td align="right" colspan="3"><input type="submit" name="submit" value="Simpan" /></td>
        </tr>
    </tbody>
</table>
</form>                        

dan berikut ini adalah file prosesnya, yang saya berinama hasil.php
<?php
$host = "localhost";
$user = "root"; 
$pass = "clasmild";
$dbname = "daftarwaralaba";
$koneksi = mysql_pconnect($host, $user, $pass) or die(mysql_error());mysql_select_db($dbname, $koneksi);

$nama= $_POST['nama'];
$noktp= $_POST['noktp'];
$JK= $_POST['JK'];
$almrm= $_POST['almrm'];
$rt= $_POST['rt'];
$kel= $_POST['kel'];
$kec= $_POST['kec'];
$kab= $_POST['kab'];
$kdp= $_POST['kdp'];
$telp= $_POST['telp'];
$hp= $_POST['hp'];
$email= $_POST['email'];
$pend= $_POST['pend'];
$kerja= $_POST['kerja'];
$jabat= $_POST['jabat'];
$almka= $_POST['almka'];
$telpkantor= $_POST['telpkantor'];

$almusulan= $_POST['almusulan'];
$rtusulan= $_POST['rtusulan'];
$kelusulan= $_POST['kelusulan'];
$kecusulan= $_POST['kecusulan'];
$kabusulan = $_POST['kabusulan'];
$kdpusulan= $_POST['kdpusulan'];
$telplokasi= $_POST['telplokasi'];
$panjang= $_POST['panjang'];
$lebar= $_POST['lebar'];
$lantai= $_POST['lantai'];
$BLK= $_POST['BLK'];
$SLK= $_POST['SLK'];
$DLK= $_POST['DLK'];
		
$daerah= $_POST['daerah'];
$budjet1= $_POST['budjet1'];
$budjet2= $_POST['budjet2'];


if ($DLK=="Ada")
{
$namafolder="gambar/"; //tempat menyimpan file
if (!empty($_FILES["nama_file"]["tmp_name"]))
{
    $jenis_gambar=$_FILES['nama_file']['type'];
    $judul_gambar=$_POST['judul_gambar'];
  
  if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
        $gambar = $namafolder . basename($_FILES['nama_file']['name']);       
        if (move_uploaded_file($_FILES['nama_file']['tmp_name'], $gambar)) {
            
$query = mysql_query("insert into web_franchise values('$nama', '$noktp', '$JK', '$almrm', '$rt', '$kel', '$kec', '$kab', '$kdp', '$telp', '$hp', '$email', '$pend', '$kerja', '$jabat', '$almka', '$telpkantor', '$almusulan', '$rtusulan', '$kelusulan', '$kecusulan','$kabusulan' , '$kdpusulan', '$telplokasi', '$panjang', '$lebar', '$lantai', '$BLK', '$SLK', '$DLK','$gambar', '$daerah', '$budjet1', '$budjet2')") or die(mysql_error());
}}
} else {
    echo "Anda belum memilih gambar";
}


			

 
//simpan data ke database


 






		$subject = 'Pendaftaran Waralaba';

		$message = "<style type=\"text/css\">
					table
					{
						border-collapse:collapse;
						border:solid 1px #CCC;
					}
					
					td
					{
						padding:5px;
					}
					
					.odd{background:#DDD;}
				</style>
				<table cellspacing=\"0\" cellpadding=\"0\">
				  <tr class=\"odd\">
					<td>Nama Lengkap</td>
					<td>$nama</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Nomor KTP</td>
					<td>$noktp</td>
				  </tr>

				  <tr>
					<td>Jenis Kelamin</td>
					<td>$JK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Alamat Rumah</td>
					<td>$almrm</td>
				  </tr>

				  
				  <tr>
					<td>RT</td>
					<td>$rt</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kelurahan</td>
					<td>$kel</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kecamatan</td>
					<td>$kec</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kabupaten</td>
					<td>$kab</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kode Post</td>
					<td>$kdp</td>
				  </tr>


				  
				  <tr class=\"odd\">
					<td>Telp</td>
					<td>$telp</td>
				  </tr>
				  
				  <tr class=\"odd\">
					<td>HP</td>
					<td>$hp</td>
				  </tr>
				  <tr class=\"odd\">
					<td>E-Mail</td>
					<td>$email</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Pendidikan</td>
					<td>$pend</td>
				  </tr>

				  
				  <tr class=\"odd\">
					<td>Pekerjaan</td>
					<td>$kerja</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Jabatan</td>
					<td>$jabat</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Alamat Kantor</td>
					<td>$almka</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Telp Kantor</td>
					<td>$telpkantor</td>
				  </tr>



				  
				  <tr class=\"odd\">
					<td>Alamat Lokasi Usulan</td>
					<td>$almusulan</td>
				  </tr>
				  
				  <tr class=\"odd\">
					<td>RT</td>
					<td>$rtusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kelurahan</td>
					<td>$kelusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kecamatan</td>
					<td>$kecusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kabupaten</td>
					<td>$kabusulan</td>
				  </tr>				  				  				  				  				  				  				  

				  <tr class=\"odd\">
					<td>Kode Post</td>
					<td>$kdpusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Telp</td>
					<td>$telplokasi</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Panjang Lokasi</td>
					<td>$panjang</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Lebar Lokasi</td>
					<td>$lebar</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Jumlah Lantai</td>
					<td>$lantai</td>
				  </tr>

				  <tr class=\"odd\">
					<td>Bentuk Lokasi</td>
					<td>$BLK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Status Lokasi</td>
					<td>$SLK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Nomor KTP</td>
					<td>$noktp</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Estimasi Bugjet</td>
					<td>$budjet1</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Budjet sampai</td>
					<td>$budjet2</td>
				  </tr>
			  				  				  
	  				  

				  
				</table>
				";

		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		$headers .= 'From: website' . "\r\n"; 

		$to      = 'emailnya@gmail.com';
		
		mail($to, $subject, $message, $headers);
}
else
{
$query = mysql_query("insert into web_franchise values('$nama', '$noktp', '$JK', '$almrm', '$rt', '$kel', '$kec', '$kab', '$kdp', '$telp', '$hp', '$email', '$pend', '$kerja', '$jabat', '$almka', '$telpkantor', '$almusulan', '$rtusulan', '$kelusulan', '$kecusulan','$kabusulan' , '$kdpusulan', '$telplokasi', '$panjang', '$lebar', '$lantai', '$BLK', '$SLK', '$DLK','$gambar', '$daerah', '$budjet1', '$budjet2')") or die(mysql_error());



		$subject = 'Pendaftaran Waralaba';

		$message = "<style type=\"text/css\">
					table
					{
						border-collapse:collapse;
						border:solid 1px #CCC;
					}
					
					td
					{
						padding:5px;
					}
					
					.odd{background:#DDD;}
				</style>
				<table cellspacing=\"0\" cellpadding=\"0\">
				  <tr class=\"odd\">
					<td>Nama Lengkap</td>
					<td>$nama</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Nomor KTP</td>
					<td>$noktp</td>
				  </tr>

				  <tr>
					<td>Jenis Kelamin</td>
					<td>$JK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Alamat Rumah</td>
					<td>$almrm</td>
				  </tr>

				  
				  <tr>
					<td>RT</td>
					<td>$rt</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kelurahan</td>
					<td>$kel</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kecamatan</td>
					<td>$kec</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kabupaten</td>
					<td>$kab</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kode Post</td>
					<td>$kdp</td>
				  </tr>


				  
				  <tr class=\"odd\">
					<td>Telp</td>
					<td>$telp</td>
				  </tr>
				  
				  <tr class=\"odd\">
					<td>HP</td>
					<td>$hp</td>
				  </tr>
				  <tr class=\"odd\">
					<td>E-Mail</td>
					<td>$email</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Pendidikan</td>
					<td>$pend</td>
				  </tr>

				  
				  <tr class=\"odd\">
					<td>Pekerjaan</td>
					<td>$kerja</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Jabatan</td>
					<td>$jabat</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Alamat Kantor</td>
					<td>$almka</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Telp Kantor</td>
					<td>$telpkantor</td>
				  </tr>



				  
				  <tr class=\"odd\">
					<td>Alamat Lokasi Usulan</td>
					<td>$almusulan</td>
				  </tr>
				  
				  <tr class=\"odd\">
					<td>RT</td>
					<td>$rtusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kelurahan</td>
					<td>$kelusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kecamatan</td>
					<td>$kecusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Kabupaten</td>
					<td>$kabusulan</td>
				  </tr>				  				  				  				  				  				  				  

				  <tr class=\"odd\">
					<td>Kode Post</td>
					<td>$kdpusulan</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Telp</td>
					<td>$telplokasi</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Panjang Lokasi</td>
					<td>$panjang</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Lebar Lokasi</td>
					<td>$lebar</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Jumlah Lantai</td>
					<td>$lantai</td>
				  </tr>

				  <tr class=\"odd\">
					<td>Bentuk Lokasi</td>
					<td>$BLK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Status Lokasi</td>
					<td>$SLK</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Nomor KTP</td>
					<td>$noktp</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Estimasi Bugjet</td>
					<td>$budjet1</td>
				  </tr>
				  <tr class=\"odd\">
					<td>Budjet sampai</td>
					<td>$budjet2</td>
				  </tr>
			  				  				  
	  				  

				  
				</table>
				";

		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		$headers .= 'From: website' . "\r\n"; 

		$to      = 'emailnya@gmail.com';
		
		mail($to, $subject, $message, $headers);
		

}






?>

Mohon dibantu ya, bagaimana agar file bisa di upload ke server dan bisa di attach ke email saya... terimakasih sekali sudah mau membantu,..
thanks

Eko Setiawan
Silahkan login untuk menjawab!
0
Loading...
Eko Setiawan · Sep 8, 2012 · 0 Suka · 0 Tidak Suka
Mas Ellyx, Saya sudah berhasil upload...

tapi ada masalah lagi, tolongin ya... masalahnya adalah file yang dikirim ke email tidak bisa menjadi attach File.. yang saya bisa menampilkan alamat URL tempat file yang di upload. saya inginkan ketika user isi form dan upload file maka isian dan file tersebut masuk ke email sekaligus.. jadi file bisa di download di gmail

apa ya mas yang kurang... mohon pencerahannya... thanks
0
Loading...
Ellyx Christian · Oct 1, 2012 · 0 Suka · 0 Tidak Suka