problem in php script to upload a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanboy
    New Member
    • Jul 2010
    • 20

    problem in php script to upload a file

    The upload html page i'm using

    Code:
    <html>
    <head> <title> </title></head>
    <body> 
    <form enctype="multipart/form-data" name="upload" action="upload.php" method="post">
    <input  name="file4upload"  type="file"> </input> <br>
    <input name="submit" type="button" value="Upload File" > 
    </form>
    </body>
    </html>

    php file code is given below (upload.php)

    Code:
    <?php
    $target_path="upload/";
    $target_path=$target_path.basename($_FILES['file4upload']['name']);
    if(move_uploaded_file($_FILES['file4upload']['tmp_name'],$target_path))
    {
    echo " File ".basename($_FILES['file4upload']['name'])."has been uploaded";
    }
    
    
    else
    {
    echo "Unsuccessful";
    }
     ?>
    i couldn't succeed in this simple upload scipt.Breaking my head for past two days.Kindly help me
    It gives me following error

    Notice: Undefined index: file4upload in C:\Documents and Settings\All Users\Documents \PHP practice\upload .php on line 3

    Notice: Undefined index: file4upload in C:\Documents and Settings\All Users\Documents \PHP practice\upload .php on line 4
    Unsuccessful


    PHP version used 5.1
    IIS version : 5.1
    OS : Win Xp

    Hope u'll all help me...Thanx
  • lyodmichael
    New Member
    • Jul 2012
    • 75

    #2
    what kind of file do you need to upload?

    Comment

    • shanboy
      New Member
      • Jul 2010
      • 20

      #3
      Solution: i had not close the <input> tag. Nowit is works.
      Last edited by Niheel; Jul 16 '12, 01:59 PM.

      Comment

      Working...