if ($data_arr) { $latitude = $data_arr[0]; $longitude = $data_arr[1]; $formatted_address = $data_arr[2]; } else { echo "No map found."; $formatted_address = $data_arr; } //Image properties if (!empty($_FILES['image'])) { $file = $_FILES['image']; $file_name = $file['name']; $file_tmp = $file['tmp_name']; $file_size = $file['size']; $file_error = $file['error']; } //Work out the Image extension $file_ext = explode('.', $file_name); $file_ext = strtolower(end($file_ext)); $allowed = array('png', 'jpg'); if (in_array($file_ext, $allowed)) { if ($file_error === 0) { $file_name_new = uniqid('', true) . '.' . $file_ext; $file_destination = 'uploads/' . $file_name_new; if (move_uploaded_file($file_tmp, $file_destination)) { $data->createEvent($post_id, $category, $title, $time, $start_date, $end_date, $formatted_address, $details, $file_destination); header("LOCATION: display.php"); } } } }