=============**************==========
file upload form
==============*************=============
<html>
<head>
<title>New Page 1</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST" action="upload.php">
<p>upload file<input type="file" name="user_file"> </p>
<p><input type="submit" value="Send File"></p>
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
</form>
</body>
</html>
================*********************================
upload.php
================*********************================
$userfile = $_FILES['user_file']['tmp_name'];
$userfile_name = $_FILES['user_file']['name'];
$userfile_size = $_FILES['user_file']['size'];
$userfile_type = $_FILES['user_file']['type'];
if ($userfile==""
{
echo "Problem: No file Uploaded";
exit;
}
if ($userfile_size==0)
{
echo "Zero Length";
exit;
}
//if ($userfile_type != "text/plain"
//{
//echo "Problem: file is not plain text";
//exit;
//}
if (is_uploaded_file($_FILES['user_file']['name']))
{
echo "Problem: possible file upload attack";
exit;
}
$target_path = "uploads/";
$target_path = $target_path.basename($_FILES['user_file']['name']);
$_FILES['user_file']['tmp_name'];
if (!move_uploaded_file($_FILES['user_file']['tmp_name'], $target_path))
{
echo "Problem: Could not move file into directory";
exit;
}
echo "File uploaded successfully<br><br>";
$fp = fopen($target_path, "r"
;
//$contents = base64_encode(@fread(fopen($target_path, 'r'), filesize($target_path) ) );
$contents = fread ($fp, filesize ($target_path));
fclose ($fp);
$contents = strip_tags($contents);
$fp = fopen($target_path, "w"
;
fwrite($fp, $contents);
fclose($fp);
echo "Preview of uploaded file contents:<br><hr>";
echo $contents;
echo "<br><hr>";
Anil sharda