You need to know, that you have 5 parameters in $_FILES['userfile']
:
- name - original name of uploaded file
- tmp_name - system name that is physically writen on disk by system
- size - size of file
- error - code of error - 0 mean no problem
- type - type of saved file
If you want you original name, to display, use simply:
$_FILES['userfile']['name']
You also have function move_uploaded_file()
, that allows you to safely move the file from a temporary place to your own. Another way, after the end of PHP process, you uploaded file will be deleted.
$path = __DIR__ . '/upload/' . basename($_FILES['userfile']['name']);
$result = move_uploaded_file($_FILES['userfile']['tmp_name'], $path);
$result
show you, is system correctly save a file in given place.