|
Serverske aplikacije i baze podataka PHP, Perl, ASP, ASP .NET, ColdFusion... MySQL, PostgreSQL, MSQL, Oracle... |
|
Alatke vezane za temu | Vrste prikaza |
12.10.2015, 19:11 | #1 |
Novi član
Član od: 25.1.2015.
Poruke: 12
Zahvalnice: 12
Zahvaljeno 0 puta na 0 poruka
|
Kako da UPDATE sliku
Cao, evo mene opet sa mojim problemima
Elem, pravim neki sajtic i sve je islo bez problema dok nije trebalo da napravim stranicu za edit. E sad, i to je islo bez problema sve dok nisam stigla do dela za editovanje ili update slike. Na stranici za edit mi se prikazuju 3 slike. E sad, kada promenim sve 3 slike ne bude nikakvih problema ali kada hocu samo 1 sliku da promenim, izbaci mi gresku. Evo i koda: Kod:
<?php require ('mysqli_connect.php'); $page_title = 'Edit'; include ('header.html'); // Check for a valid user ID, through GET or POST: if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // From view_users.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form submission. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<p class="error">This page has been accessed in error.</p>'; exit(); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Potkresivanje svih primljenih vrednosti $trimmed = array_map('trim', $_POST); if (isset($_FILES['upload1'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload1']['type'], $allowed)) { // Move the file over. if (move_uploaded_file ($_FILES['upload1']['tmp_name'], "includes/uploads/{$_FILES['upload1']['name']}")) { $i = $_FILES['upload1']['name']; } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or PNG image.</p>'; } } // End of isset($_FILES['upload']) IF. // Check for an error: if ($_FILES['upload1']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload1']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. if (isset($_FILES['upload2'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload2']['type'], $allowed)) { // Move the file over. if (move_uploaded_file ($_FILES['upload2']['tmp_name'], "includes/uploads/{$_FILES['upload2']['name']}")) { $sl = $_FILES['upload2']['name']; } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or PNG image.</p>'; } } // End of isset($_FILES['upload']) IF. // Check for an error: if ($_FILES['upload2']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload2']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. if ($m && $mo && $k && $g && $gr && $me && $v && $ku && $b && $kl && $p && $p1 && $c1 && $c2 && $c3 &&$c4 &&$c5 &&$c6 && $va && $o && $i && $sl && $bl) { // ako je sve ok $q = "UPDATE kola SET marka='$m', model='$mo', karoserija='$k', godiste='$g', gorivo='$gr', menjac='$me', vrata='$v', kubikaza='$ku', boja='$b', klasa='$kl', po_gradu='$p', po_putu='$p1', cena1='$c1', cena2='$c2', cena3='$c3', cena4='$c4', cena5='$c5', cena6='$c6', valuta='$va', opis='$o', slika1='$i', slika2='$sl', slika3='$bl' WHERE kola_id=$id LIMIT 1"; $r = @mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error:" . mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { header("Location: indexadmin.php"); exit(); }else{ echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } mysqli_close($dbc); // Close the database connection. // Obrisati fajl ako jos uvek postoji if (file_exists ($_FILES['upload1']['tmp_name']) && is_file($_FILES['upload1']['tmp_name']) ) { unlink ($_FILES['upload1']['tmp_name']); } if (file_exists ($_FILES['upload2']['tmp_name']) && is_file($_FILES['upload2']['tmp_name']) ) { unlink ($_FILES['upload2']['tmp_name']); } if (file_exists ($_FILES['upload3']['tmp_name']) && is_file($_FILES['upload3']['tmp_name']) ) { unlink ($_FILES['upload3']['tmp_name']); } } ?> Gde gresim Hvala na strpljenju i razumevanju |
Bookmarks sajtovi |
Alatke vezane za temu | |
Vrste prikaza | |
|
|
Slične teme | ||||
tema | temu započeo | forum | Odgovora | Poslednja poruka |
Kako se radi update BIOS-a? | Gija | Osnovne komponente | 27 | 15.8.2013 11:56 |
Kako nelepiti sliku preko slike različitih dimenzija | Sinisa Milovanovic | Grafički softver i radovi | 2 | 16.8.2011 14:25 |
Kako izmeniti sliku? | zakzizu | Foto i audio/video | 3 | 5.11.2010 1:50 |
Kako zameniti sliku | aca2568 | Grafički softver i radovi | 3 | 11.7.2010 10:48 |
Kako da izbrišem Windows Genuine (to je Windows Update) | Master Of The Air | Aplikativni softver | 1 | 24.4.2007 12:06 |