Setting the "upload_tmp_dir" folder of a cloud server

Asked

Viewed 1,125 times

0

I am trying to upload media to my server with a php code. I have already redone the code a few times and I believe that there is absolutely nothing wrong. I researched on the subject and saw that my folder upload_tmp_dir is worth no value. Vale remembers that the same code on the pc works perfectly.

I tried to set some folder by the command line, but I got nothing,

i access php.ini and there is so:

inserir a descrição da imagem aqui

How can I then set the temporary file folder. Because I believe this will end my problems

I even used the following code ::

<?php
    $field = 'arquivo';
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="POST">
    <input name="<?php echo $field;?>" type="file" />
    <input type="submit" value="send" />
</form>

This code says that the file was in the /tmp/ folder, but the upload command is not working, I can not upload anything by php code.

Code I use to TRY to upload

<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
  if(isset($_POST['cadastrar'])){

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

  $titu           = filter_input(INPUT_POST, 'titu');

  if(empty($titu)){
  echo "<div style='width:500px; text-align:center;'><font style='font-weight:bold'>Preencha Todos os Campos</font></div";  
  }else{        

  $variavel = $titu;            
  //Conversao Concluida
  $urll = strtolower( preg_replace('/[^a-zA-Z0-9-]/', "_", 
  strtr(utf8_decode(trim($variavel)), utf8_decode("áàãâéêíóôõúüñçÁÀÃÂÉÊÍÓÔÕÚÜÑÇ")
  ,"aaaaeeiooouuncAAAAEEIOOOUUNC")) ); 

  //Exibindo a variavel limpa, sem nenhum espaço ou caracter especial
  echo $urll;   
  $name = uniqid().'.'.$ext;
  try{

  $stmte = $pdo->prepare("INSERT INTO post(TITULO, IMAGEM, URL) VALUES (:1, :2, :3)");
  $stmte->bindParam(":1",  $titu  , PDO::PARAM_STR);
  $stmte->bindParam(":2",  $name  , PDO::PARAM_STR);
  $stmte->bindParam(":3", $urll  , 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();
  }}}
?> 

1 answer

3


Try to do the following, remove the ; of upload_tmp_dir and set a value for it, for example:

Of:

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
; upload_tmp_dir = 

To:

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = "/tmp"
  • is. This helps defining the tmp folder, however it did not solve the problem I’m having! Uploading the file is still impossible for me

  • It seems that I do not work first, but now it started working!! The code is the same, so I believe it was thanks to this!

Browser other questions tagged

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