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 ???

Recommended Answers

All 19 Replies

Why don't you just password protect the folder the files are in?

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 ?

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.

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

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

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.

<?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.';
}
?>
<?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();
?>

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

If you remove line 31 from 1.php it should view the file.

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

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.

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 :) :)

Where did you download this?

Please type regular full sentence english, try to avoid the leet speak.

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 :) :)

I'll try again: where did you download this?

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

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.

aha sorry there is no indications in that..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.