anonīms Posted March 13, 2008 Report Share Posted March 13, 2008 http://paste.php.lv/6980 Lieta tāda, ka katru reizi labojot 'Saturs', bildi vienmēr arī vajag uplodot, citādi viņa no db pazūd. Kā varētu izveidot, lai viņš pārbauda, vai pie [browse] ir pievienota bilde un ja nav, tad lai to nemaz nesūta uz db? Link to comment Share on other sites More sharing options...
Aleksejs Posted March 13, 2008 Report Share Posted March 13, 2008 pirms 11. rindiņas ieliec kaut ko šādu: if isset($_FILES['reklamas_bilde']){ ..11.rinda } Link to comment Share on other sites More sharing options...
anonīms Posted March 13, 2008 Author Report Share Posted March 13, 2008 (edited) Tas nelīdz function modifySaturs() { $sveiciens = $_POST['txtSveiciens']; $par_mums = $_POST['txtParMums']; $kontakti = $_POST['txtKontakti']; $email = $_POST['txtEmail']; $reklama_teksts = $_POST['txtReklama_teksts']; if(isset($_FILES['reklamas_bilde'])){ $reklama_bilde = augshupladejam_bildi('reklamas_bilde', SRV_ROOT . 'images/reklama/'); //$stalys = $_FILES['reklamas_bilde']['name']; //$reklama_bilde = htmlspecialchars($stalys); $reklamas_bilde_liela = $reklama_bilde['image']; $reklamas_bilde_maza = $reklama_bilde['thumbnail']; $sql = "UPDATE tbl_saturs SET sveiciens = '$sveiciens', par_mums = '$par_mums', kontakti = '$kontakti', email = '$email', reklama_bilde = '$reklamas_bilde_maza', reklama_teksts = '$reklama_teksts'"; $result = dbQuery($sql); echo "UPDATE tbl_saturs SET sveiciens = '$sveiciens', par_mums = '$par_mums', kontakti = '$kontakti', email = '$email', reklama_bilde = '$reklamas_bilde_maza', reklama_teksts = '$reklama_teksts'"; header("Location: index.php"); } } <input name="reklamas_bilde" type="file" class="box"> Edited March 13, 2008 by anonīms Link to comment Share on other sites More sharing options...
andrisp Posted March 13, 2008 Report Share Posted March 13, 2008 if ($_FILES['reklamas_bilde']['error'] == UPLOAD_ERR_OK) { } http://lv2.php.net/manual/en/features.file-upload.errors.php Link to comment Share on other sites More sharing options...
anonīms Posted March 13, 2008 Author Report Share Posted March 13, 2008 Izveidoju mazliet savādāk $reklama_bilde = augshupladejam_bildi('reklamas_bilde', SRV_ROOT . 'images/reklama/'); $bilde_no_datubazes = mysql_query("SELECT reklama_bilde FROM tbl_saturs"); $bilde_no_datubazes = mysql_fetch_array($bilde_no_datubazes); //$stalys = $_FILES['reklamas_bilde']['name']; //$reklama_bilde = htmlspecialchars($stalys); $reklamas_bilde_liela = $reklama_bilde['image']; $reklamas_bilde_maza = $reklama_bilde['thumbnail']; if($reklamas_bilde_liela != ''){ $reklamas_bilde_liela = $reklamas_bilde_liela; $reklamas_bilde_maza = $reklamas_bilde_maza; } else { // if we're not updating the image // make sure the old path remain the same // in the database $reklamas_bilde_maza = $bilde_no_datubazes[0]; } Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 14, 2008 Report Share Posted March 14, 2008 [Lieta tāda, ka katru reizi labojot 'Saturs', bildi vienmēr arī vajag uplodot, citādi viņa no db pazūd. parbaude elementara .. if($_FILE['bilde'][temp_name] !='') { // bilde ir ... apstradajam vinju $tralji_valji=' reklama_bilde = '$reklamas_bilde_maza', '; } else { // bildes nav ... $tralji_valji=''; } $sql = "UPDATE tbl_saturs SET sveiciens = '$sveiciens', par_mums = '$par_mums', kontakti = '$kontakti', email = '$email', $tralji_valji reklama_teksts = '$reklama_teksts'"; P.S. prieks kam 2 reizes rakstiji Kveriju ? 2 reiz labak echo $sql; Link to comment Share on other sites More sharing options...
Recommended Posts