Error while doing image update in database

Asked

Viewed 40 times

3

Notice: Undefined index: flefoto in C: xampp htdocs Inf4m asteroide controllers usuario_controller.php on line 17

Notice: Undefined index: flefoto in C: xampp htdocs Inf4m asteroide controllers usuario_controller.php on line 19

Filing cabinet views/cadastro_usuario.php

<form action="router.php?controller=usuario&modo=novo" method="post">

<input id="teste" class="botao_foto_perfil" type="file" name="flefoto"/>

<input class="box_text" type="text" name="txtnome">

<input class="box_text" type="text" name="txtemail">

Filing cabinet php router.

$controller = $_GET['controller'];
$modo = $_GET['modo'];

switch($controller){
  case 'usuario':

  require_once('controllers/usuario_controller.php');
  require_once('models/usuario_class.php');

  switch($modo){
    case 'novo':

    $controller_usuario = new controllerUsuario();
    $controller_usuario::Novo();
    break;
  }
}
 ?>

Filing cabinet controllers/usuario_controller.php

class controllerUsuario {

  public function Novo(){

    $usuario = new Usuario();

    if($_SERVER['REQUEST_METHOD']=='POST'){

        //Tratamnto de arquivo
        $arq = basename($_FILES['flefoto']['name']);

        $caminho = $_FILES['flefoto']['tmp_name'];

            if(strstr($arq,'.jpg') || strstr($arq,'.png') ||strstr($arq,'.gif')){
                    $usuario->foto = $_POST['flefoto'];
                }else{
                    echo("Este não é um arquivo de imagem");
                }

            }

    $usuario->nome = $_POST['txtnome'];
    $usuario->email = $_POST['txtemail'];
    $usuario->senha = $_POST['txtsenha'];

...
  • $_POST['flefoto']; there is no.

  • where I create her?

  • I believe you’re trying to do the following instead of: $usuario->foto = $_POST['flefoto']; would be $usuario->foto = $arq;

  • You’ve already solved?

  • For images, you search with the $_FILES, and not $_POST. Look at the Woss link.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.