Site icon T4Tutorials.com

How to view the uploaded resume in PHP

How to view the uploaded resume in PHP (Code).

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

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

$temporary = explode(".", $_FILES["file"]["name"]);
$filetype = end($temporary);
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($filetype, $filetypepERSMISSION))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br><br>";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br><br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br><br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br><br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br><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>

 

Exit mobile version