0

The upload html page i'm using

<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)

<?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

Edited by Dani: Fixed formatting

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by shanboy
0

I made a typing mistake
i haven't closed the <input> tag.it should be

<input name="submit" type="button" value="Upload File" >

</input> after <input name="submit" type="button" value="Upload File" >
Now it works
problem solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.