0

hi i want to upload and post my pdf material in my site and its my personal institute material so i dnt want to give the download option for that file so how it is can anybody help me ???

2
Contributors
19
Replies
20
Views
5 Years
Discussion Span
Last Post by ratanji
Featured Replies
0

actually m uploading pdf files al they are seeming download option beside the row bt i dnt knw how to give view option for that soo can u hlp me ?

Edited by ratanji

0

You may want to try to explain a little better. What do you have, and what are you having problems with? Perhaps a picture or some code will help.

0

Name ** **Batch Mime Size (bytes) Created Download
(sqlinterview.pdf) (2) (application/pdf) (133370) (2012-10-04 18:23:09) (Download)

Edited by ratanji

0

actually output is seeming like this but i want view option also for that pdf so how can i put view option for that ?

0

How is this outputted? Is it a script you wrote? Is it a script you downloaded? You'd need at least to show a code snippet that shows how this output was generated.

0
<?php

if(isset($_GET['id'])) {

    $id = intval($_GET['id']);


    if($id <= 0) {
        die('The ID is invalid!');
    }
    else {

        $dbLink = new mysqli('localhost', 'root', 'root', 'emp');
        if(mysqli_connect_errno()) {
            die("MySQL connection failed: ". mysqli_connect_error());
        }


        $query = "SELECT `mime`, `name`, `size`, `data` FROM `file` WHERE `id` = {$id}";
        $result = $dbLink->query($query);

        if($result) {

            if($result->num_rows == 1) {

                $row = mysqli_fetch_assoc($result);


                header("Content-Type: ". $row['mime']);
                header("Content-Length: ". $row['size']);
                header("Content-Disposition: attachment; filename=". $row['name']);


                echo $row['data'];
            }
            else {
                echo 'Error! No file exists with that ID.';
            }


            @mysqli_free_result($result);
        }
        else {
            echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
        }
        @mysqli_close($dbLink);
    }
}
else {
    echo 'Error! No ID was passed.';
}
?>
0
<?php

$dbLink = new mysqli('localhost', 'root', 'root', 'emp');
if(mysqli_connect_errno()) {
    die("MySQL connection failed: ". mysqli_connect_error());
}


$sql = 'SELECT `id`, `name`, `batch`, `mime`, `size`, `created` FROM `file`';
$result = $dbLink->query($sql);


if($result) {

    if($result->num_rows == 0) {
        echo '<p>There are no files in the database</p>';
    }
    else {

        echo '<table width="100%">
                <tr>
                    <td><b>Name</b></td>
        <td><b>Batch</b></td>
                    <td><b>Mime</b></td>
                    <td><b>Size (bytes)</b></td>
                    <td><b>Created</b></td>
                    <td><b>&nbsp;</b></td>
                </tr>';


        while($row = $result->fetch_assoc()) {
            echo "
                <tr>
                    <td>{$row['name']}</td>
        <td>{$row['batch']}</td>
                    <td>{$row['mime']}</td>
                    <td>{$row['size']}</td>
                    <td>{$row['created']}</td>
                    <td><a href='1.php?id={$row['id']}'>Download</a></td>
        <td><a href='del.php?id={$row['id']}'><center>Delete</center></a></td>
                </tr>";
        }


        echo '</table>';
    }


    $result->free();
}
else
{
    echo 'Error! SQL query failed:';
    echo "<pre>{$dbLink->error}</pre>";
}


$dbLink->close();
?>
0

these are the code i downloaded in net bt i dnt knw how to put view option for pdf sooo

0

displaying same output and downloading too that file..no change in output by removing that line in 1.php

0

Okay. Why don't you contact the author of the script? He has a better understanding of what he made. Perhaps the option is already in his code and you just need to enable it.

0

hmm thanq but actually i dnt knw the author who z i forgt that frm wer i dwnloaded dats y i askd u anyway thanx alot and chill dude if u get solution for that plz post in it :) :)

Edited by ratanji

0

ok sorry actually i dnt know the author who is ! i forgot that from where i dwnloaded dats y i asked u anyway thanx alot and chill dude if u get solution for that plz post in it :) :)

0

i dont knw from where i downloaded!! in google i searched some site and downloaded in one of the site

0

Aha, misread. Isn't there any indication in the code or a readme where it came from? Hard to help if I don't know what you have.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.