Sunday 15 June 2014

html - How can I allow user to upload own PDF and have it displayed? -



html - How can I allow user to upload own PDF and have it displayed? -

i have website school every teacher going have page. each teacher's page have spot them upload pdf. want show in viewer on page students see viewer when access it.

how code website allowing user upload pdf , not have replaced until else uploads pdf?

so far have code upload document.

<form method="post" enctype="multipart/form-data" action="fup.cgi"> file upload: <input type="file" name="upfile"><br/> notes file: <input type="text" name="note"><br/> <br/> <input type="submit" value="press"> upload file! </form>

how can go viewer below? , saves until replaced.

1 - first thing not able upload file server form action claiming utilize cgi, 2 - sec cant want next code can upload files server in php , otherthing using sql or database using seems need database

<?php set_time_limit(0); if(!is_dir("uploads")){ $uploaddir = mkdir("uploads"); } $allowedexts = array("pdf", "docx", "doc"); $extension = end(explode(".", $_files["file"]["name"])); if ((($_files["file"]["type"] == "application/pdf") || ($_files["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_files["file"]["type"] == "application/msword")) && ($_files["file"]["size"] < 200000000000000) && 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("/uploads/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { move_uploaded_file($_files["file"]["tmp_name"], "/uploads/" . $_files["file"]["name"]); echo "stored in: " . "/uploads/" . $_files["file"]["name"]; } } } else { echo "invalid file"; } ?>

do want display pdf thumb, icon, or read pdf

html pdf

No comments:

Post a Comment