I want the user to be able to upload photos to the site folder using a button (and for their further output). He writes that he uploaded a photo, although it does not appear in the site folder. What have I done wrong?
<? include '/db.php'; ?> <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> </head> <body> <form enctype="multipart/form-data" method="post" action="/index.php"> <input name="picture" type="file"> <input type="submit" value="Загрузить"> </form> <? $path = '/avatars'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!@copy($_FILES['picture']['tmp_name'], $path . $_FILES['picture']['name'])) { echo 'Что-то пошло не так'; } else { echo 'Фотография удачно загружена!'; } } ?> </body> </html>
Возможная атака с помощью файловой загрузки! Некоторая отладочная информация:Array ( [picture] => Array ( [name] => 4prX6WSofMU.jpg [type] => [tmp_name] => [error] => 2 [size] => 0 ) )