How to view our uploaded resume online with php in website

<?php
if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit']) == 'upload')
{
var_export($_POST); 

$allowedExts = array("pdf", "doc", "docx");



$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "application/msword")
|| ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    if (file_exists("resume/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "resume/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "resume/" . $_FILES["file"]["name"];

      $sql = mysqli_query($con,"update user_personal_details 
      set resume='".$_FILES["file"]["name"]."' where user_id='".$_SESSION['user_id']."'");

      }
    }
  }
else
  {
  echo "Invalid file";
  }
}
?>


<form action="update_resume.php" method="post" enctype="multipart/form-data" >
<input type="file" name="file" />
<input type="submit" name="submit" value="upload" />
</form>

<?php 

echo $id1=$_SESSION['user_id'];
$sql="SELECT *FROM user_personal_details WHERE user_id='$id1'";
$res=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($res))
{?>
<br/>

<br/>
<table cellpadding="5" cellspacing="3" style="border:1px solid #808080;" width="100%">
<tr>
<td class="blaaa"><b>Resume</b></td><td class="blaaa"><a href="resume/<?php echo $row['resume']; ?>" target="_blank">View Here</a></td></tr>
<?php
}
?>
</table>
Member Avatar
diafol

Is it a question, a code snippet or what?

Maybe the OP wants to display pdfs, docs and docxs within the web browser? As in render it inside the browser.

its a question. how to view doc file online using php?????????????

I think we need to sort things out.

Viewing it as a file is the easiest, all you have to do is provide the url of the doc file and the user will be able to view it, depending on the user's desktop and browser's settings.

Viewing it as regenerated file created by parsing a doc file is a different method and it is a lot harder to achieved.

Viewing a doc file as generated by PHP from the collected data through a form is highly feasible. If you want to go for this option, you can use this class.