Ejemplo n.º 1
0
 $listing->userId = $_SESSION['userId'];
 $listing->name = $_POST['name'];
 $listing->description = $_POST['description'];
 $listing->species = $_POST['species'];
 $listing->sex = $_POST['sex'];
 $listing->zip = $_POST['zip'];
 $listing->age = $_POST['age'];
 $listing->breed = $_POST['breed'];
 $listing->deSexed = $_POST['deSexed'];
 $listing->declawed = $_POST['declawed'];
 $listing->microchipped = $_POST['microchipped'];
 $listing->outdoor = $_POST['outdoor'];
 $listing->hypoallergenic = $_POST['hypoallergenic'];
 $listing->dateSubmitted = date("Y-m-d H:i:s");
 $listing->dateModified = date("Y-m-d H:i:s");
 $listing->save();
 for ($i = 0; $i < 4; $i++) {
     if (isset($_FILES['photo']) && !empty($_FILES['photo']['tmp_name'][$i])) {
         $photo = new Photo();
         $photo->petListingId = $listing->id;
         $uploadOk = 1;
         // Directory where file gets placed
         $target_dir = "../" . MEDIA_URL . "photos/";
         $target_file = $target_dir . basename($_FILES["photo"]["name"][$i]);
         $image_file_type = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
         $filename = $_FILES["photo"]["name"][$i];
         // Check file size
         if ($_FILES["photo"]["size"][$i] > 5000000) {
             $_SESSION["errormsg"] = "Sorry, your file is too large. Keep it under 5mb";
             $uploadOk = 0;
         }