ps2pdf.php

こんなかんじじゃなかろうかと。

# cat ps2pdf.php 
<html>
<head><title>ps2pdf</title></head>
<body>
<br /><br />
< ?
    $command = ‘/usr/bin/ps2pdf’;
    $dir = "/var/www/html";
    if (!empty($_FILES)) {
      $uploadedFile = $_FILES[‘uploadedFile’][‘tmp_name’];
      $fileName = $_FILES[‘uploadedFile’][‘name’];
      $file = $dir . ‘/’ . $fileName;
      move_uploaded_file($uploadedFile, $file);

      $exeCommand = $command . ‘ ‘ . $file;
      exec($exeCommand, $output, $ret);

      $downloadFileName = ereg_replace(‘\.ps$’, ‘.pdf’, $fileName);
      $downloadFile = ‘<a href="’ . $downloadFileName . ‘">’ . $downloadFileName . ”;
      echo $downloadFile;
?>
< ?
    } else {
?>
<form enctype="multipart/form-data" action="/ps2pdf.php" method="post">
    <input type="file" name="uploadedFile"/>
    <input type="submit" value="submit"/>
</form>
< ?
    }
?>
</body>
</html>

同じカテゴリの記事: Program