I want to upload a file to a given folder.
<?php $folder = "upload/"; if (is_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'])) { if (move_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) { echo "File uploaded"; } else { echo "File not moved to destination folder. Check permissions"; }; } else {s echo "File is not uploaded"; }; ?>
The error is:
Note: Undefined variable: HTTP_POST_FILES in C:\wamp\www\sdg\import\ips.php on line 3
PHP 4.1 introduces Super global. They replace the old long named arrays that contained the data extracted from the request.
$_FILES[]
Replaced$HTTP_POST_FILES[]
,$_GET[ ]
Replaced$HTTP_GET_VARS[]
WaitFor subsequent PHP 4 versions, old arrays and new arrays can be used side by side. PHP 5 disables the generation of old arrays by default and introduces the
php.ini directive
register_long_arrays
which can be used to re-enable old arrays create.As of PHP 5.4, the old long named arrays are completely removed and
register_long_arrays
disappear with them.Conclusion: You are learning from a very old or very bad tutorial. Find a better one.
The following is one way to upload files, there are many other ways.
As @nordenheim said,
$HTTP_POST_FILES
is deprecated as of PHP 4.1.0, so its use is not recommended.PHP code (upload.php)
HTML code to activate the function
Hope this helps.