I'm trying to create an upload file script but am getting Undefined variable errors.
I have tow pages, page1 with the browse and upload file and page two which catches the file once its been uploaded.
the important bits form page1 are as follows:
<form enctype="multipart/form-data" action="upload.php" method=post >
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
<input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
and from page 2 (upload.php).....
Uploading File.....
<?
if ($userfile=="none")
{
echo "Problem: No file has been received.";
exit;
}
if ($userfile_size==0)
{
echo "Problem: Uploaded file is empty.";
exit;
}
if ($userfile_type!="text/plain")
{
echo "Problem: File does not appear to be plain text.
Only upload plain .txt documents";
exit;
}
if (!is_uploaded_file($userfile))
{
echo "Problem: Security warning, possible file upload exploit.
Process shutdown";
exit;
}
$upfile = " /".$userfile_name;
if (!copy($userfile, $upfile))
{
echo "Problem: Could not store the uplaoded file";
exit;
}
echo "File upload completed sucesfully<br><br>";
$fp = fopen($upfile, "r");
$contents = fread ($fp, filesize ($upfile));
fclose ($fp);
$contents = strip_tags($contetns);
$fp = fopen($upfile, "w");
fwrite($fp, $contents);
fclose($fp);
echo "Upload contents - check and confirm.";
echo $contents;
?>
roor is in the first refernece to userfile
what am i doing wrong??
Any help much appreciated!!