Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
- <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
- </head>
- <body>
- <?php
- define("UPLOAD_PATH","/var/www/html/konwertuj_pdf/f/");
- ini_set('upload_max_filesize', '999999999');
- if(is_uploaded_file($_FILES['ffilen']['tmp_name'])){
- $fileinfo = pathinfo($_FILES[ffilen][name]);
- if ($fileinfo['extension']!="exe" && $fileinfo['extension']!="php"){
- $path = UPLOAD_PATH.$_FILES[ffilen][name];
- if(!move_uploaded_file($_FILES['ffilen']['tmp_name'],$path)){
- echo '<p class="error">problem: Nie udało się skopiować pliku</p>';
- }
- else{
- shell_exec ("chmod 777 -R '".UPLOAD_PATH."'");
- //podliczenie stron pdf
- $c = "pdfinfo '".UPLOAD_PATH.$_FILES[ffilen][name]."' | grep Pages | sed 's/[^0-9]*//'";
- $pgs = shell_exec ($c);
- //konwertowanie stron pdf do jpg
- $c = "gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=".$pgs." -sOutputFile=".UPLOAD_PATH."output%d.jpg -dJPEGQ=90 -r500 -q '".UPLOAD_PATH.$_FILES[ffilen][name]."' -c quit";
- echo $c;
- shell_exec ($c);
- //usuwanie pdf
- $c = "rm '".UPLOAD_PATH.$_FILES[ffilen][name]."'";
- shell_exec ($c);
- //spakowanie do zipa wszystkich zdjec
- $c = " zip -r ".UPLOAD_PATH."out.zip /var/www/html/konwertuj_pdf/f/*.*";
- shell_exec ($c);
- //usuwanie zdjec
- $c = "rm ".UPLOAD_PATH."*.jpg";
- shell_exec ($c);
- echo '<p class="success">Plik zawiera '.$pgs.' stron. <a href="http://192.168.0.110/konwertuj_pdf/f/out.zip">Kliknij by pobrac.</a></p>';
- }
- }
- else{
- echo '<p class="error">problem: Niedozwolony format pliku</p>';
- }
- }
- ?>
- <form enctype="multipart/form-data" action="index.php" method="post" class="box">
- <h1>Prześlij plik PDF</h1>
- <p>
- <label>
- <span>Plik</span>
- <input type="file" name="ffilen" />
- </label>
- </p>
- <p><input type="submit" value="Wyślij" class="button"/></p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment