pls i want how to upload and retrive only pdf files in php and mysql code or any links..

<?php
$targetPath = $_SERVER['DOCUMENT_ROOT'].'/upload/';

if (isset($_POST['submit'])){

$filename = basename( $_FILES['file']['name'], ".pdf");

if($_FILES['file']['type']=='application/pdf') {
        $filename = preg_replace("/[^A-Za-z0-9_-]/", "", $filename).".pdf";
        $thumb = basename($filename, ".pdf");
        $cpy=1;
        do {
            $targetFile =  str_replace('//','/',$targetPath) ."Copy".$cpy. $filename;
            $filename="Copy".$cpy. $_FILES['file']['name'];
            $cpy++;
        }while(is_file($targetFile));

            if(move_uploaded_file($_FILES['file']['tmp_name'], $targetPath.$filename)) {             
                    $pdfWithPath = $targetPath.$filename;
                    echo "File Uploaded Successfully";
            }
}
else {
    echo "Please Upload pdf File";  
}
}

?>

<form method="post" action="" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" name="submit" value="Upload" />
</form>

Check your $targetPath path is correct and give 777 permission for folder upload

thanq soo much darling :)

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.