File Upload

2

I have the following code below:

PHP:

<?php
    $nome_temporario = $_FILES["Arquivo"]["tmp_name"];
    $nome_real = $_FILES["Arquivo"]["name"];
    copy($nome_temporario, "/public_html/publico/$nome_real");
?>

HTML:

<form action="upload.php" method="post" enctype="multipart/form-data"> 
    <input type="file" name="Arquivo" id="Arquivo"/>

    <input type="submit" value="Enviar"/>
    <input type="reset" value="Apagar"/>
</form>

I would like to know what is wrong, because when I try to upload, it appears this error message:

  

Warning: copy (/public_html/publico/teste.txt) [function.copy]: failed to open stream: No such file or directory in /home/opeao802/public_html/upload/upload.php on line 4

p>
    
asked by anonymous 18.11.2015 / 21:41

1 answer

4

The error message says that the /public_html/publico folder does not exist. Make sure it exists and you have permission to save files within it.

Check the exact location of the folder

Enter the relative folder name or complete ../publico or /home/opeao802/public_html/publico

Ex:

<?php
    $nome_temporario = $_FILES["Arquivo"]["tmp_name"];
    $nome_real = $_FILES["Arquivo"]["name"];
    copy($nome_temporario, "../publico/$nome_real");
?>

Or

<?php
    $nome_temporario = $_FILES["Arquivo"]["tmp_name"];
    $nome_real = $_FILES["Arquivo"]["name"];
    copy($nome_temporario, "/home/opeao802/public_html/publico/$nome_real");
?>
    
18.11.2015 / 21:45