K
K
Kirill2016-01-12 00:07:53
PHP
Kirill, 2016-01-12 00:07:53

How to make an image title?

Hello! There is a code that works well, the point is that it uploads a file to a folder on the hosting with the name of the file that was on the local, but I need the name of the file that was in the folder that I wanted, how to do it?

<?php
// В PHP 4.1.0 и более ранних версиях следует использовать $HTTP_POST_FILES 
// вместо $_FILES.

$uploaddir = 'images/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "Файл корректен и был успешно загружен.";
} else {
    echo "Возможная атака с помощью файловой загрузки!\n";
}

echo 'Некоторая отладочная информация:';
print_r($_FILES);

print "</pre>";

?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sunrails, 2016-01-12
@quant78

Everything is detailed here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question