Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Upload PDF file in php

Sun Oct 26, 2008 9:31 pm

The code will rename the file too ,
Code:

 <form action="<?php print $PHP_SELF?>" enctype="multipart/form-data" method="post">
Last name:<br /> <input type="text" name="name" value="" /><br />
class notes:<br /> <input type="file" name="classnotes" value="" /><br />
  <input type="submit" name="submit" value="Submit Notes" />
</form>

<?php
 define 
("filesplace","./");

 if (is_uploaded_file($_FILES['classnotes']['tmp_name'])) {

 if ($_FILES['classnotes']['type'] != "application/pdf") {
 echo "<p>Class notes must be uploaded in PDF format.</p>";
 } else {
 $name = $_POST['name'];
 $result = move_uploaded_file($_FILES['classnotes']['tmp_name'], filesplace."/$name.pdf");
 if ($result == 1) echo "<p>Upload done .</p>";
 else echo "<p>Sorry, Error happened while uploading . </p>";
}
 #endIF
 } #endIF
?>




Re: Upload PDF file in php

Fri May 10, 2013 12:04 am

updated.

Post a reply
  Related Posts  to : Upload PDF file in php
 File Upload in JSP     -  
 JSP to Upload File     -  
 Upload File to a new directory     -  
 upload file in ajax     -  
 Upload PHP file code     -  
 Struts2 upload file and ajax     -  
 PHP HTML form with to file upload     -  
 Encrypt/Decrypt a file from source file to target file.     -  
 Upload Form     -  
 Servlets how to upload Files     -  

Topic Tags

PHP Files and I/O