How to view the uploaded resume in PHP
How to view the uploaded resume in PHP (Code).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<?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> |