Problem uploading files to server

-1

I'm learning how to use a cloud server and am having trouble uploading files.

I made a simple PHP and HTML code:

<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="img" />
<input type="text" name="titu" placeholder="Titulo" />
<input class="lal" type="submit" name="cadastrar" value="Cadastrar" >    
</form>

<?php
  require_once 'conexao.php';
  if(isset($_POST['cadastrar'])){

    /* IMAGEM */
    $img    = $_FILES['img'];
    $name   = $img ['name'];
    $tmp    = $img ['tmp_name'];
    $size   = $img ['size'];
    $ext    = end(explode('.',$name));      
    $pasta    = "../imagem/";
    $maxSize    = 1024 * 1024;
    $permiti    = array('jpg', 'jpeg', 'png');         
    $titu         = filter_input(INPUT_POST, 'titu');

    if(empty($titu)){echo "Informe um titulo";  
    }else{      

      $name = uniqid().'.'.$ext;
      try{    
          $stmte = $pdo->prepare("INSERT INTO post(TITULO, IMAGEM) VALUES (:1, :2)");
          $stmte->bindParam(":1", $titu  , PDO::PARAM_STR);
          $stmte->bindParam(":2", $name  , PDO::PARAM_STR);   
          $executa = $stmte->execute();

          if($executa){        
            echo 'Dados inseridos com Sucesso';
            $upload   = move_uploaded_file($tmp, $pasta.$name);   
          }
          else{
            echo 'Erro ao inserir os dados';
          }
        }
    catch(PDOException $e){
    echo $e->getMessage();
    }}}
?> 

And the BD registration is happening perfectly, so much so that I can get into phpMyAdmin and see there the newly added record as well as updating the home page where the posts are displayed.

But as you can see, I'm uploading an image file but, even though the record is being inserted into the DB successfully, move_uploaded_file does not move the temporary file as it should.

And this is my problem because I have to post the post with the image, but since it is not being sent, it does not exist.

I do not understand why, since if I run the code on my PC, with WAMP, both registration and upload work normally. And on the server it seems to work, as it does not return any error messages, but the upload is not done.

I do not think it's some wrong code because I've used this same code multiple times on shared servers and it always worked. The problem is just this cloud server.

I think the problem might be in the cloud configuration itself, since I even changed the permission of the images folder to 777 and nothing.

I also changed some PHP.INI directives as shown in the image below:

Would anyone know the cause of this?

    
asked by anonymous 05.12.2014 / 02:23

1 answer

5
  

Note: This response was posted before the questioner changed the code. question later , based on screenshot , may be the cause of the problem.

05.12.2014 / 12:04