0

Marking the question as duplicate is futile, cause I've referred all such questions on SO and none of them did provide a solution.

<?php 
if(isset($_POST['submit'])){
$name=$_FILES['filedoc']['name'];  
$temp_name=$_FILES['filedoc']['tmp_name'];  
if(isset($name)){
    if(!empty($name)){      
        $file=file_get_contents($temp_name);
        }
    }
else echo"Please upload file";

echo "<form action=\"";echo htmlentities($_SERVER["PHP_SELF"]);echo "\" method=\"post\">
    <h2>New Paste</h2>
    <label> Upload File?  <input type = \"file\" name = \"filedoc\"/></label><br><span class=\"error\">";echo $fileErr;echo"</span><br>
    <input id=\"button\"class=\"red\" type =\"submit\" class=\"red\" name=\"submit\" value = \"Paste\"/><br><span class=\"error\">";echo $submitErr;echo "</span>
    </form>";
}
?>

Form is being displayed correctly. So there are no errors in the second part. But then, I get this error ( ! ) Notice: Undefined index: filedoc in path of the file

2 Answers 2

2

form attribute enctype="multipart/form-data" is missing

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help!
0

The form also needs the following attribute: enctype="multipart/form-data". It specifies which content-type to use when submitting the form Without the requirement above, the file upload will not work.

1 Comment

Thanks for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.