mysql upload slika

mysql upload slika

offline
  • Pridružio: 18 Dec 2007
  • Poruke: 95

e ovako nesto sam ja napravio kao ubacujes podatke u bazu zajedno sa slikom samo to nesto nije bas dobro.Posto cini mi se ne ubacuje u bazu i samim tim necita ili ja nisam ni citanje slike iz baze napravio evo koda:
<form action="Uneseno1.php" name="myform" ENCTYPE="multipart/form-data" method="post"> <table  class="mytable" align = "center"> <tr> <td>Marka</td> <td><input type ="text" name="marka" maxlenght="20" size="20"></td> </tr> <tr> <td>Model</td> <td><input type ="text" name="model" maxlenght ="20" size="20"></td> </tr> <tr> <td>Cena</td> <td><input type ="text" name ="cena" maxlenght ="20" size="20"></td> </tr> <tr> <td>Godiste</td> <td><input type="text" name="godiste" maxlenght="20" size="20"></td> </tr> <tr> <td>Boja</td> <td><input type="text" name="boja" maxlenght="20" size="20"></td> </tr> <tr> <td>e-mail</td> <td><input type="text" name="email" maxlenght="30" size="20"></td> </tr> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"> <tr><td>Upload File: <INPUT NAME="slike" TYPE="file"></td></tr> <tr><td><input type="submit" name="submit" value="Update"></td></tr> </table> </form> </body> </html>

<?php $marka = $_POST['marka']; $model = $_POST['model']; $cena = $_POST['cena']; $godiste = $_POST['godiste']; $boja = $_POST['boja']; $email = $_POST['email']; $slike = $_POST['slike']; if (!$marka || !$model || !$cena || !$godiste  || !$boja || !$email) {   echo 'Niste uneli tražene podatke.<br>'.        'Molimo vas pokušajte ponovo.';   exit; } if(!get_magic_quotes_gpc()) {  $marka = addslashes($marka);  $model = addslashes($model);  $cena  = doubleval($cena);  $godiste = addslashes($godiste);  $boja = addslashes($boja);  $email = addslashes($email);  $slike = addslashes($slike); } @ $db = new mysqli('shadow','ford','escort','automobili'); if (mysqli_connect_errno()) {   echo 'Greska neuspesno povezivanje sa bazom.'.        'Molimo pokusajte ponovo.';   exit; } $query = "insert into automobili values            ('".$marka."','".$model."','".$cena."','".$godiste."','".$boja."','".$email."','".$slike."')"; $result = $db->query($query); if($result)  echo 'Podaci su uspesno unešeni.<br>'; $db->close(); print("$marka<br>"); print("$model<br>"); print("$cena<br>"); print("$godiste<br>"); print("$boja<br>"); print('<p><a href="mailto:'.$email.'">'.$email.'</a></p>'); print("$slike<br>"); ?> <?php $uploaded=0; $utime=time(); $uday= date('d'); $umonth= date('m'); $uyear= date('y'); print('<html>'); print('<head><title>'); print('Upload File Example</title>'); print("</head>"); print('<body>'); print('<h2>Upload File Example</h2>'); $udate=$umonth.$uday.$uyear; echo "Date:".$udate."<br>"; echo "Time:".$utime."<br>"; $filename="a".$udate.$utime; echo "Create a unique name for a new file from date and time.<br>"; echo "Filename::".$filename."<br>"; $target_path = "upload/"; $target_path = $target_path . basename( $_FILES['slike']['name']); echo "Target_path::".$target_path."<br><br>"; $_FILES['slike']['tmp_name']; // temp file $target_path = "upload/"; //for my pc echo "Read original name of the uploaded file <br>"; $original_file = basename($_FILES['slike']['name']); echo "Original file::".$original_file."<br><br>"; echo "Getting the extention the file extension <br>"; $pos = strpos($original_file,".",0); $ext = trim(substr($original_file,$pos+1,strlen($original_file))," "); echo "extension::".$ext."<br>"; echo "Assemble new file name and extension <br>"; $newfile = $filename . "." . $ext; echo "New file name::".$newfile."<br><br>"; echo "Move the file to the final destination <br>"; $target_path = $target_path . basename($newfile); echo "Target_path::".$target_path."<br><br>"; if(move_uploaded_file($_FILES['slike']['tmp_name'], $target_path)) { $uploaded=1; $message="Fajl je ". basename( $_FILES['slike']['name']). " uspesno poslat"; } else { $message="Doslo je do greske prilikom slanja, molimo vas pokusajte ponovo!"; } echo $message; if($uploaded==1) print('<img src="upload/'.$newfile.'">'); ?>
eto pa ako je neko voljan.



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • igor86  Male
  • Stručni saradnik
    Web programiranje
  • Pridružio: 24 Maj 2006
  • Poruke: 1633

Pa de barem 10 min debaguj script, pa vidi od koje linije nisi zadovoljan.



Ko je trenutno na forumu
 

Ukupno su 968 korisnika na forumu :: 36 registrovanih, 6 sakrivenih i 926 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: 357magnum, A.R.Chafee.Jr., ajo baba, BORUTUS, cavatina, comi_pfc, Dannyboy, DejanSt, Denaya, djboj, doktor1964, DPera, Georgius, janbo, Još malo pa deda, Lošmi, Metanoja, Milan A. Nikolic, mile33, Mirage 2000N, moldway, operniki, powSrb, prekodrinski, procesor, proka89, raptorsi, sasa87, stegonosa, styg, tmanda323, User98, vathra, Vlada78, voja64, ZetaMan