php - extracted pdf page and pdf files are not uploaded for some of the pdf files -


i use imagemagic/ghostscript script below extract first page of pdf file , convert jpg format , use html form upload the jpg picture along pdf file , other information wamp server. suprise, upload pdf files , goes confirmation page activated when upload successful. some, returns $err message. can please hep me out?

<?php include ('head.php');     include ('connect.php');      if(isset($_post['submit'])) {           $pdfdirectory = "pdf/";         $thumbdirectory = "pdfimage/";          //get name of file         $filename = basename( $_files['pdf']['name'], ".pdf");          //remove characters file name other letters, numbers, hyphens , underscores         $filename = preg_replace("/[^a-za-z0-9_-]/", "", $filename).".pdf";          //name thumbnail image same pdf file         $thumb = basename($filename, ".pdf");                   $title=$_post['title'] ;                 $author= $_post['author'] ;                  $pub = $_post['pub'];                                $abstract= $_post['abstract'] ;                 $year= $_post['year'] ;                 $category= $_post['cat'] ;                           if(move_uploaded_file($_files['pdf']['tmp_name'], $pdfdirectory.$filename)){                          //the path pdf file                         $pdfwithpath = $pdfdirectory.$filename;                           //add desired extension thumbnail                         $thumb = $thumb.".jpg";                          //execute imagemagick's 'convert', setting color space rgb , size 200px wide                         exec("convert \"{$pdfwithpath}[0]\" -colorspace rgb -background white -geometry 200 -flatten $thumbdirectory$thumb");                          //show image                         //echo "<p><a href=\"$pdfwithpath\"><img src=\"pdfimage/$thumb\" alt=\"\" /></a></p>";                          $imagez = "pdfimage/$thumb";                          $query ="insert books (title, author, publisher, abstract, year, category, book, bkimage) values ('".$title."', '".$author."', '".$pub."', '".$abstract."', '".$year."', '".$category."', '".$filename."', '".$imagez."')" ;          $result = mysql_query($query);          if (!$result) {             $err = "could not add library @ time";         } else {             header('location:confirm.php');              }                     }         }   ?> 

add books library

title author publisher abstract year category select... architecture building engineering civil engineering computer electrical engineering land survey general management mechanical engineering quantity survey others upload book    

instead of

$err = "could not add library @ time"; 

do this:

$err = "could not add library @ time. sql: ".$query; 

if not able see problem is, connect mysql , run query. should able see mysql error (which asking in first answer =)).


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -