php - Form won't submit properly while trying to upload a PDF -


i have form user can upload images can't seem work .pdf.

this form kinda looks like:

<form enctype="multipart/form-data" method="post" action="newfacility.php">     <label for="photo">facility roof plan:</label>                          <input type="file" id="facilityroofplan" name="facilityroofplan" />     <input type="submit" value="create" name="submit" /> </form> 

newfacility.php looks this:

error_reporting(e_all);                 ini_set('display_errors', 1);         if (isset($_post['submit'])) {      $facilityid = 10;     selectedassocaccount = 5;       $directorypath =  "../images/" . $selectedassocaccount . "/" . $facilityid;        mkdir($directorypath, 0775);      //facility roof plan     if(!empty($_files["facilityroofplan"]["name"])){          //directory path facility photo reside in         $facilityroofplan = "../images/". $selectedassocaccount ."/" . $facilityid . "/" . basename($_files["facilityroofplan"]["name"]);                                            if($_files['facilityroofplan']['error'] == upload_err_ok) {             $status_msg = '';             $from = $_files["facilityroofplan"]["tmp_name"];             $saved = save_facility_roof_plan($from, $facilityroofplan, $status_msg);             if (!$saved) {                 echo "error saving roof plan image: {$status_msg}";             }         } else{             echo "error uploading facility image.";                      }     } } else{     echo "error, unexpected happened, please try again."; } 

i told not worry file size @ - not going worry it.

this function save_facility_roof_plan looks like:

function save_facility_roof_plan($from, $to, &$status_msg) {     // check if file exists     if (file_exists($to)) {         $status_msg = "sorry, facility photo exists.";         return false;     }      if (move_uploaded_file($from, $to)) {         $status_msg = "the file ".basename($to)." has been uploaded.";         return true;     }     $status_msg = "sorry, there error uploading photo.";     return false; } 

now, issue having when user clicks submit thing happens thrown error message - "error, unexpected happened, please try again."

i have no issues while trying upload images @ (.jpeg, .png, etc.) can't submit form while trying upload .pdf. first time have ever tried upload .pdf directory quite lost.

why form not submit @ while trying upload .pdf?

how can form upload pdf set directory?


Comments