How to change image upload code to work in mysql?

0

I got this code to upload image to work in PostgreSQL, but I would like to change it to work in phpMyAdmin, but I'm finding a certain difficulty, and I'd like to count on the help of friends.

The code looks like this:

//Instancia a clase passando o arquivo (atributo name no form).
$logo = "";
if (isset($_FILES["logo"]))
{
    $dir_dest = "../upload";
    $upload = new Upload($_FILES['logo'], $dir_dest);

// verifica se foi realizado corretamente o Upload
if ($upload->processed){
$logo = $upload->file_dst_name;
}
}

$objImagemlogo = new Imagemlogo();
$objImagemlogo->codigo = $_POST["codigo"];
$objImagemlogo->logo = $logo;
$objImagemlogo->atualizar();
?>

The name in the upload file is Upload.php.

I tried to do the following:

   <form name="enter" method="post" action="Upload.php" enctype="multipart/form-data">
   <label>Código:</label></br>
   <input type="number" name="codigo" value="<?php echo $res['codigo'];?>" readonly="readonly"></br>
   <label>Imagem Atual:</label></br>
   <img width="200" height="auto" src="../upload/<?php echo $res['logo'];?>"/></br>
   <label>Imagem:</label></br>
   <input type="file" name="logo" ></br>
   <input class="input" type="submit" name="enter" value="Atualizar" /></br>
   </form>

I thought bringing the Upload.php file to action would work, but I was wrong. And now I have no idea how to change the code so it can work on the project in Mysql.

If friends can give me this help, I'll be grateful.

Hugs to everyone, and BRIGADAN right away.

As requested below is the entire contents of the object's query file:

    <?php
    include_once 'BD.class.php';
    class Imagemlogo {
    private $codigo;
    private $logo;

    //variaveis internas
    private $bd; //conexão com o banco
    private $tabela; //nome da tabela

    public function __construct() {
    $this->bd = new BD();
    $this->tabela = "pagcabecalho";
    }
    public function __destruct() {
    unset($this->bd);
    }

    public function __get($key) {
    return $this->$key;
    }

    //método de retorno de valores do objeto 
    public function __set($key, $value) {
    $this->$key = $value;
    }

    public function listar($complemento = "") {
    $sql = "SELECT * FROM $this->tabela ".
                    $complemento;

    $resultado = pg_query($sql);
    $retorno = NULL;
    //percorre os registros
    while ($reg = pg_fetch_assoc($resultado)) {
        //transforma em objetos produto
        $obj = new Imagemlogo();
        $obj->codigo = $reg["codigo"];
        $obj->logo = $reg["logo"];
        //adiciona a variavel de retorno
        $retorno[] = $obj;
    }
    return $retorno;
    }

    public function excluir() {

    $sql = "delete from $this->tabela where codigo=$this->codigo";
    $retorno = pg_query($sql);
    return $retorno;
    }

    public function retornarunico() {
    $sql = "Select * FROM $this->tabela where codigo=$this->codigo LIMIT 1";

    $resultado = pg_query($sql);
    $retorno = NULL;

    $req = pg_fetch_assoc($resultado);
    if ($req == true) {
        $obj = new Imagemlogo();
        $obj->codigo = $req["codigo"];
        $obj->logo = $req["logo"];

        $retorno = $obj;
    } else {
        $retorno = null;
    }

    return $retorno;
    }
    public function atualizar() {
    $retorno = false;
    $sql = "UPDATE $this->tabela SET logo='$this->logo' WHERE codigo=$this->codigo";
    $retorno = pg_query($sql);
    return $retorno;
    }
    }
    ?>
    
asked by anonymous 09.09.2015 / 23:41

0 answers