0

Can someone please explain this code, i am following a very good book that was recommended to me and I have typed the code exactly as it is in the book. it displays the code instead of out, I am not sure what is wrong, the code is from a book called php solutions

          <?php
                     // set the max upload size in bytes
                      $max = 51200;
                     if(isset($_POST['upload'])){

                // define the path to the upload folder
                $destination = 'C:\upload_test';
                 // move the file to the uplaod folder and rename it
                move_uploaded_file($_FILES['image']
                    ['tmp_name'],     $destination.$_FILES['image']['setara']);

                    }
                    ?>







    <!doctype html>
    <html  lang="en">
    <head>
    <meta charset="utf-8">
    <title>Mult</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>





    <form action="" method="post" enctype="mutipar/form-data" id="uploadImage">
        <p>
            <label for="image">Upload image:</label>
            <input type="hidden"name="MAX_FILE_SIZE" value="<?php echo $max; ?>">

            <input type="file" name="image" id="image">
        </p>
        <p>
            <input type="submit" name="upload" id="upload" value="Upload">
        </p>
    </form>






</body>
</html>
9
  • Is file's extension is .html or .htm? Commented May 1, 2013 at 8:45
  • @ClarksonJey isnt both are same ? Commented May 1, 2013 at 8:46
  • how you are running file and what is file extension ? Commented May 1, 2013 at 8:46
  • Are you doing that on a server with php instaleled? Commented May 1, 2013 at 8:47
  • 1
    localhost/file_uploads/file_upload.php the output is the code nothing else Commented May 1, 2013 at 9:06

1 Answer 1

2

This is surely because you are writing PHP code in .html or .htm extension file try putting the code with .php extension file. It will resolve error.

Sign up to request clarification or add additional context in comments.

1 Comment

This answer isn't based on any facts, there may be more options to cause this failure. For example: PHP not installed/enabled, if the OP dragged the file directly in the browser it will also fail etc etc... Please post this as a comment next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.