Uploading files

Discussion in 'PHP' started by Shaimaa, Jul 17, 2009.

  1. #1
    I have a wamp server installed on my machine
    I tried to upload file
    I used this codes
    in the first file

    <html>
    <body>

    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>

    </body>
    </html>

    the second file

    <?php
    if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "<br />";
    }
    else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
    }
    ?>

    I run it from the localhost

    the result was

    Upload: BF1065E_Bride_in_White.jpg
    Type: image/jpeg
    Size: 51.90234375 Kb
    Stored in: C:\wamp\tmp\php34CD.tmp

    I don't find the red colored path

    I don't know what is the problem

    what's wrong with the previous code?

    I am waiting for your replay as soon as possible

    Thank you in advance

    Beginner PHP Developer
     
    Shaimaa, Jul 17, 2009 IP
  2. mioot

    mioot Peon

    Messages:
    169
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi Shaimaa,
    U seeing the path in red color is temporary folder, u want to move that file from temp to your destination path (or) file. You don't consider about that. Use the below code and check weather ur uploaded file get stored in your provided path it is enough. Because the tmp folder may hidden from user.
    move_uploaded_file($_FILES["file"]["tmp_name"],'filename.extension');
     
    mioot, Jul 18, 2009 IP