File Upload

Asked

Viewed 81 times

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

1 answer

4


Error message says the folder /public_html/publico does not exist. Check if it exists and if you are allowed to save files within it.

Check the exact location of the folder

Enter the relative name of the folder 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");
?>
  • I have general access, and running the code inside the server, it’s all released on the Cpanel. The folder does exist, but I don’t know why it can’t copy inside '-'

  • see the edited response

  • I tried, it no longer appeared error message, but also did not upload T.T file

  • which of the options you used? test using the /home/opeao802/public_html/publico/ to ensure

  • this option even I used.

  • I don’t see any more errors, some new message or Warning appears?

  • I had put public or instead of public in the answer, by chance you don’t have a public folder so the file might be inside it

  • no, I had noticed, but I didn’t change anything. all right as the folders

  • If not already, test put permission777 in the folder p view

  • face, now that I saw it, he copied to the previous folder the folder I informed. I wonder what happened?

  • All right old man, I missed the same path.

  • Set as your code is now

  • Blza q good q worked

Show 8 more comments

Browser other questions tagged

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