public function addPostFile($field, $filename = null, $contentType = null, $postname = null)
 {
     $data = null;
     if ($field instanceof PostFileInterface) {
         $data = $field;
     } elseif (is_array($filename)) {
         // Allow multiple values to be set in a single key
         foreach ($filename as $file) {
             $this->addPostFile($field, $file, $contentType);
         }
         return $this;
     } elseif (!is_string($filename)) {
         throw new RequestException('The path to a file must be a string');
     } elseif (!empty($filename)) {
         // Adding an empty file will cause cURL to error out
         $data = new PostFile($field, $filename, $contentType, $postname);
     }
     if ($data) {
         if (!isset($this->postFiles[$data->getFieldName()])) {
             $this->postFiles[$data->getFieldName()] = array($data);
         } else {
             $this->postFiles[$data->getFieldName()][] = $data;
         }
         $this->processPostFields();
     }
     return $this;
 }
Example #2
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . "/header.php";
$countryObj = new GetCountry($_GET['name']);
$country = $countryObj->info();
$title = $country['name'];
if (!$country) {
    die("Страна не найдена");
}
if (is_numeric($_GET['delete'])) {
    $data = $db->where('id', $_GET['delete']);
    $data = $db->where('country_id', $country['id']);
    $data = $db->delete('Country_point');
}
if (is_numeric($_POST['modal_point']) and $_GET['editfile'] == 1) {
    $file = new PostFile($_POST['modal_point']);
    if ($_FILES["file"]["name"]) {
        //замена центральной фотки
        if (!$file->upload($_FILES)) {
            $loc = $country['name'] . "?error=" . $file->getErrorMsg();
            header("Location: {$loc}");
        } else {
            $loc = $country['name'] . "?add_point=" . $_POST['modal_point'] . '#Point' . $_POST['modal_point'];
            header("Location: {$loc}");
        }
    } elseif ($_POST['file_url']) {
        if ($file->uploadFromurl($_POST['file_url'])) {
            $loc = $country['name'] . "?add_point=" . $_POST['modal_point'] . '#Point' . $_POST['modal_point'];
            header("Location: {$loc}");
        } else {
            $loc = $country['name'] . "?error=" . $file->getErrorMsg();