Answers for "upload pdf file in php"

PHP
0

upload pdf file in php

<html>
<head>
<title>  FORM </title>
</head>
<body align="left">
<h1> FILE UPLOAD </h1>

<form action = "term5b.php" method = "POST" enctype="multipart/form-data"/>

    <input type = "file" name = "fileupload"/></br>  
    <input type = "submit" name = "opt" value = "upload"/></br> </br>  

</form>
</body>
</html>







<?php
   $target_dir="E:\ ";
   $filename=$_FILES["fileupload"]["name"];

   $tmpname=$_FILES["fileupload"]["tmp_name"];
   $filetype=$_FILES["fileupload"]["type"];
   $errors=[];
   $fileextensions=["pdf"];
	$arr=explode(".",$filename);
   $ext=strtolower(end($arr));

   $uploadpath=$target_dir.basename($filename);
if(! in_array($ext,$fileextensions))
   {
     $errors[]="Invalid filename";
   }
   if(empty($errors))
   {
     if(move_uploaded_file($tmpname,$uploadpath))
     {
       echo "file uploaded successfully";
     }
     else
     {
       echo "not successfull";
     }
   }
   else
   {
      foreach($errors as $value)
      {
         echo "$value";
      }
   }
?>
Posted by: Guest on March-18-2021
0

view uploaded pdf file in php

<?php include 'filesLogic.php';?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="style.css">
    <title>Files Upload and Download</title>
  </head>
  <body>
    <div class="container">
      <div class="row">
        <form action="index.php" method="post" enctype="multipart/form-data" >
          <h3>Upload File</h3>
          <input type="file" name="myfile"> <br>
          <button type="submit" name="save">upload</button>
        </form>
      </div>
    </div>
  </body>
</html>
Posted by: Guest on September-07-2020

Browse Popular Code Answers by Language