0

I am trying to upload a local file to webserver using HTML POST method and PHP. this is my php code:

<?php


if (isset($_POST["submit"])) {
$updir = "/var/tmp/";
$upfile = $updir.basename($_FILES['rawexcel']['name']);

if(is_uploaded_file ($_FILES ["rawexcel"]["tmp_name"]))
{
move_uploaded_file ($_FILES["rawexcel"]["tmp_name"], $upfile);

} else {echo "error uploading file ".$upfile;}
} else {echo "not isset post method";}
?>

and HTML code is:

<div class="container" id="upl">
<h4> Upload files</h4>
<form action="upl.php" enctype="mutipart/form-data" method="post">
<p> upload your files to DB</p>
<p><input type="file" name="rawexcel" id ="rawexcel"> 
<input type ="submit" value="Upload" name ="submit"></p>
</form>
</div>

$_FILES["rawexcel"]["error"] shows 0 and from running this peice of code i get

error uploading file /var/tmp    

I guess file name was not retrieved from html?

3
  • 2
    What error you are getting...? Commented Jul 19, 2017 at 10:22
  • 1
    Updated question. In short - cant get filename, $upfile is only $updir Commented Jul 19, 2017 at 10:26
  • 1
    upvotes on a typo? wow Commented Jul 19, 2017 at 11:24

2 Answers 2

3

Error is in enctype:

enctype="multipart/form-data" 

not:

enctype="mutipart/form-data"
Sign up to request clarification or add additional context in comments.

Comments

1

You have typo mistake in enctype="multipart/form-data" , instead of this you typed enctype="mutipart/form-data" . So "mutipart" spelling is need to correct.

Comments

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.