codice HTML:
<html>
    <head>
        <title>upload PDF</title>
    </head>
    <body>
        <form action="upload.php" method="POST" enctype="multipart/form-data"> 
        <input placeholder="Carica un file PDF" class="nome" type="text" />
        <input class="allegato" accept="application/pdf"  type="file" name="fileup" />  
        <input class="invia" type="submit" name='submit' value="Carica" />  
        </form>
    </body>
</html>
Codice PHP:
<?php 

ERROR_REPORTING
(E_ALL);

$input "fileup";
$uploadpath "img/allegati/";
$max_size 204800// 200 kB

$allowtype = array("application/pdf");

if(empty(
$_FILES[$input])){
    
trigger_error("Nessun file caricato."E_USER_ERROR);
}else{

    
$file $_FILES[$input]['tmp_name'];
    
$file_name $_FILES[$input]['name'];
    
$file_type $_FILES[$input]['type'];
    
$size $_FILES[$input]['size'];
    
$err $_FILES[$input]['error'];

    if(
$allowtype[0] != "*"){
        if(!
in_array($file_type$allowtype)){
            @
unlink($file);
            
trigger_error("File non valido."E_USER_ERROR);
            exit;
        }
    }
    
    switch(
$err){
        case 
'1':
        case 
'2':
            
trigger_error("Le dimensioni del file sono eccessive."E_USER_ERROR);
            exit;
        break;
        case 
'3':
        case 
'6':
            
trigger_error("Si è verificato un errore durante l'upload."E_USER_ERROR);
            exit;
        break;
        case 
'4':
            
trigger_error("Non hai selezionato nessun file."E_USER_ERROR);
            exit;
        break;
        case 
'0':

        if(
$size $max_size){
            @
unlink($file);
            
trigger_error("Le dimensioni del file sono eccessive."E_USER_ERROR);
            exit;
        }

        
$nuovo_nome_file_dopo_upload $file_name// qui puoi scegliere il nuovo nome da dare al file dopo l'upload
        
$tnam $uploadpath.$nuovo_nome_file_dopo_upload;
        
move_uploaded_file($file$tnam);
            
        echo 
'File: <b>'basename($file_name). '</b> caricato con successo:';
        echo 
'<br/>File type: <b>'$file_type .'</b>';
        echo 
'<br />Dimensione: <b>'number_format($size/10243'.''') .'</b> KB';

        
pdf2jpg($tnam);

        break;
    }
    
}

function 
pdf2jpg($tnam){

    
$pdf $tnam;
    
$save preg_replace("/(.*\.)(.*)/""\\1"."jpg"$pdf);
    
$output "";

    
exec("convert {$pdf} -colorspace RGB -resize 800 {$save}"$output$return);

    
// print $return;

}

?>