PHP-File uploaded does not go to the directory defined

Asked

Viewed 61 times

0

$arquivocom = $_FILES['submetidocom']['name'];
    $diretoriocom = "C:/Users/NEWGRID/Documents/uploadcom/";
    move_uploaded_file($_FILES['submetidocom']['tmp_name'], $diretoriocom.$arquivocom);
    if (file_exists($arquivocom)){  
         echo"<script language='javascript' type='text/javascript'>alert('Arquivo 2 já existente, por favor renomeio-o e tente novamente');</script>";

    }else{
         echo"<script language='javascript' type='text/javascript'>alert('Upload 2 feito com sucesso!');</script>"; 
    }

HTML

                 <input type="hidden" name="MAX_FILE_SIZE" value="30000">            
                <input type="file" class="form-control-file" name="submetidocom" value="<?php echo $submetidocom; ?>" id="submetidocom" required="" autofocus="">
          </div>
  • Shows no error ?

  • No, the file name and directory saved in the bank but the file does not go to folder

  • You use IIS in your environment?

  • How is set the "upload_tmp_dir" directive in your php.ini?

  • Do not use IIS, "upload_tmp_dir" looks like this: ;upload_tmp_dir =

  • You have permission to write in the directory ?

  • If you are trying to write in directories after the root of your site example your site ta in the folder c:/localhost/meusite and try to write in c:/usuairos/othern will give problem if you do not have write permission

  • I do have access

  • Check your directives post_max_size, upload_max_filesize. There is a checklist that can help you here: https://stackoverflow.com/questions/12531408/setting-php-tmp-dir-php-upload-notworking

  • These directives had already changed some time ago to be able to import the database.

  • So try using the function copy() instead of move_uploaded_file() Thus: copy($_FILES['submetidocom']['tmp_name'], $path);

Show 6 more comments

1 answer

0

Guys thanks a lot for the help, but I managed to solve, turns out I was putting the move_uploaded_file before the condition and should be put after. Now it’s working right.

  • Man, what a trick the rascal had on me. However, your question says one thing your problem was another. Seeing here I believe that at least one file you could upar before dw bump into the problem of n getting more. If this were said, it would clarify the problem further. Anyway, congratulations on having found and shared the solution.

Browser other questions tagged

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