HOW TO VIEW AN UPLOADED FILE IN PHP ?
Rahul R
rahul9629@gmail.com
------------------------------------------------------------------------------------------------------------------------------------
We can use google document viewer to view an uploded file.
Step 1:Go to google document viewer https://docs.google.com/viewer
Step 2:Enter your filename(http://yoursite.com/uploads/resumename.doc) in to the google document viewer textbox.Then click generate link
Step 3: Copy the needed link(iframe or href) from google document viewer.
Step 4:Then paste in to your page.
----------------------------------------------------------------------------------------------------------------------------------
1.index.php
----------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<h1>VIEW FILE</h1>
<h3>Direct redirection to the google document viewer</h3>
<!-- It will redirect to the google document viewer -->
<a href="https://docs.google.com/viewer?url=http://yoursitename.com/uploadfoldername/filename.doc">View File</a>
<br/><br/>
<h3>Integrating Gogle viewer to Our Project</h3>
<!-- Redirect to our own next page there we will view the document -->
<a href="resume_view.php?doc=filename.doc">File view in our page</a>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------------
2.resume_view.php (Integrating Google document viewer to our page)
----------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Document Viewer/Downloads</title>
</head>
<body style="margin:auto;">
<div id="container">
<div class="header1">
<h1>DOCUMENT VIEWER AND DOWNLOADS</h1>
</div>
<?php
// Getting the file name
if(isset($_REQUEST['doc']))
{
$filename = $_REQUEST['doc'];
}
?>
<div class="content">
<!--Generate the iframe from google document viewer and copy iframe to our page-->
<iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fyoursitename.com%2Ffoldername%2F<?php echo $filename ?>&embedded=true" width="75%" height="1000" style="border: none;"></iframe>
</div>
</div>
</body>
</html>
No comments:
Post a Comment