Jump to content
Fórum Script Brasil
  • 0

Update no upload


Gabriel Maricato

Question

Bom dia galera, blzera?

vou postar minha dúvida...

eu tenho um painel de controle de um site:

http://www.bmjardins.com.br/site/projetos_comercial.php

no painel de controle eu coloco o titulo e as imagens.. na hora de inserir no banco de dados vai certinho..

eu to apanhando na hora de 'atualizar' ou seja dar um UPDATE..

esse é o meu código:

} elseif($evento=="editar"){

    $codnoticia = $_GET["codnoticia"];
    $titulo = $_POST["titulo"];
        
    $foto = $HTTP_POST_FILES['imagem']['tmp_name'];
    $nome = $HTTP_POST_FILES['imagem']['name'];
    $fotoA = $HTTP_POST_FILES['imagemA']['tmp_name'];
    $nomeA = $HTTP_POST_FILES['imagemA']['name'];

    $local = "../../../uploads/projetos_comercial/" . $nome;
    $localA = "../../../uploads/projetos_comercial/" . $nomeA;
    
    if (!copy($foto, $local)){
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', where codnoticia = $codnoticia");
    } else {
        
        $url = "http://www.bmjardins.com.br/uploads/projetos_comercial/$nome";
        if(empty($url)){    }
        $urlA = "http://www.bmjardins.com.br/uploads/projetos_comercial/$nomeA";
        if(empty($urlA)){  }
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', imagem = '$url', imagemA = '$urlA' where codnoticia = $codnoticia");
    }
    $conexao->Executar();
}

header("location:painel.php");    

?>
só que se eu alterar 1 imagem a outra fica sem imagem, gostaria de saber como posso fazer para se eu quiser alterar 1 imagem só a outra permanece a que era.. deu pra entender? eu fiz esse
$url = "http://www.bmjardins.com.br/uploads/projetos_comercial/$nome";
        if(empty($url)){    }

pra tenrar resolver, mas ainda nada... alguém tem uma sugestão?

Valeu!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

consegui.. hahaha

fiz assim:

if (!copy($foto, $local)){
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', where codnoticia = $codnoticia");
    } else {
        $url = "http://www.bmjardins.com.br/uploads/projetos_comercial/$nome";
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', imagem = '$url' where codnoticia = $codnoticia");
    }
    $conexao->Executar();

    if (!copy($fotoA, $localA)){
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', where codnoticia = $codnoticia");
    } else {
        $urlA = "http://www.bmjardins.com.br/uploads/projetos_comercial/$nomeA";
        $conexao->SetSQL("UPDATE projetos_comercial SET titulo = '$titulo', imagemA = '$urlA' where codnoticia = $codnoticia");
    }
    $conexao->Executar();

um iF para cada imagem.. hehe

Edited by Gabriel Maricato
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...