Upload and Rename PDF

<form action=“<?php print $PHP_SELF?>” enctype=“multipart/form-data” method=“POST”>
<b>Is my agent watching out for me?</b><br />
Choose PDF file to upload: <input name=“pdffile” type=“file” /><br />
<input type=“submit” value=“Upload File” />
define (“PDFDIRECTORY”,”public_html/demo/pdf/”);
if (is_uploaded_file($_FILES[‘pdffile’][‘tmp_name’])) {
if ($_FILES[‘pdffile’][‘type’] != “application/pdf”) {
echo “<p style=’color:red;’>Please upload only PDF format.</p>”;
} else {
$result = move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’], PDFDIRECTORY.”/”.$_FILES[‘pdffile’][‘name’]);
if ($result == 1) echo “<p>File successfully uploaded.</p>”;
else echo “<p>There was a problem uploading the file.</p>”;
} #endIF
} #endIF

Leave a Reply