#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    File uploading error


    i try upload file use this code but i have this error "Notice: Use of undefined constant upload - assumed 'upload' in C:\xampp\htdocs\abc\index.php on line 5" please help me.thanks
    <?php
    if ($_POST[upload] == "1") {
    $to = "uploads/" . $_FILES['file']['name'];
    move_uploaded_file($_FILES['file']['tmp_name'], $to);
    echo "Uploaded";
    }
    ?>
    <form enctype="multipart/form-data" method="post">
    <input type="hidden" name="upload" value="1">
    <input type="file" name="file">
    <input type="submit" value="upload">
    </form>
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    PHP Code:
    if ($_POST[upload] == "1") { 
    Missing the quotes on that array key. Simple stuff.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Smile


    post just gets the variable from the form. so you have to use
    if (isset($_POST['upload'])).
    it works well...

    Comments on this post

    • paulh1983 disagrees : do YOU have to copy/paste the answer which someone has given earlier on in all your posts? this wont give you rep points!

IMN logo majestic logo threadwatch logo seochat tools logo