How to save a file after downloading through $FILE. Code exa... open

How to save a file after downloading through $FILE. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

Test form:

<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <form method="post" enctype="multipart/form-data">

        <input type="file" name="file">

        <button type="submit">Send</button>

    </form>


</body>
</html>

PHP form processing:

<?php

if (!empty($_FILES)) {
    if (move_uploaded_file($_FILES['file']['tmp_name'], "upload/{$_FILES['file']['name']}")) {
        echo 'Success';
    } else {
        echo 'Error';
    }
}
?>
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation