Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

356
Visualizações
Upload and store image in database with RedBean PHP

I have 2 files: signup.php and profile.php. When I register on signup.php with RedBean PHP everything is working, but on profile page, when I want to upload and show my image I can not do this. Phpmyadmin create new row and I can not link image with specific user. Please assist to solve it using RedBean, also, add ajax to not to restart page if it is possible.

html:

<form method="post" enctype="multipart/form-data">
    <label>Picture Profile</label>
    <input type="file" name="profile" class="form-control" required="" accept="*/image">
    <button type="submit" name="btn-add" style="color: red;">Add New </button>
</form>

php:

<?php 
    
    if(isset($_POST['btn-add']))
    {
        $name=$_POST['user_name'];

        $images=$_FILES['profile']['name'];
        $tmp_dir=$_FILES['profile']['tmp_name'];
        $imageSize=$_FILES['profile']['size'];

        $upload_dir='uploads/';
        $imgExt=strtolower(pathinfo($images,PATHINFO_EXTENSION));
        $valid_extensions=array('jpeg', 'jpg', 'png', 'gif', 'pdf');
        $picProfile=rand(1000, 1000000).".".$imgExt;
        move_uploaded_file($tmp_dir, $upload_dir.$picProfile);
        $stmt=$db_conn->prepare('INSERT INTO tbl_user(username, picProfile) VALUES (:uname, :upic)');
        $stmt->bindParam(':uname', $name);
        $stmt->bindParam(':upic', $picProfile);
        if($stmt->execute())
        {
            ?>
            <script>
                alert("new record successul");
                window.location.href=('index.php');
            </script>
        <?php
        }else 

        {
            ?>
            <script>
                alert("Error");
                window.location.href=('index.php');
            </script>
        <?php
        }

    }
?>

Many thanks

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda