POST file upload

@param  string $filename File to be uploaded

@return mixed
@throws InvalidArgumentException
181551
public function addPostFile($filename)
    {
        if ($filename instanceof UploadedFile) {

            // Get original filename
            $name = $filename->getClientOriginalName();

            // Move the file
            $file = $filename->move(sys_get_temp_dir() . '/' . uniqid(), $name);

            // Get the new file path
            $filename = $file->getRealPath();
        }

        if (!is_readable($filename)) {
            throw new InvalidArgumentException("Unable to open {$filename} for reading");
        }

        // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
        // See: https://wiki.php.net/rfc/curl-file-upload
        if (function_exists('curl_file_create')) {
            return curl_file_create($filename);
        }

        // Use the old style if using an older version of PHP
        return "@{$filename}";
    }
192437
public function saveToFile($FileName = null)
    {
        if (! is_null($FileName)) {
            $this->FileName = $FileName;
        }

        if (($this->_openSHPFile(true)) && ($this->_openSHXFile(true)) && ($this->_createDBFFile())) {
            $this->_saveHeaders();
            $this->_saveRecords();
            $this->_closeSHPFile();
            $this->_closeSHXFile();
            $this->_closeDBFFile();
        } else {
            return false;
        }
    }
287688
protected function getFileContent($filename)
    {
        if (!file_exists($filename)) {
            throw new \InvalidArgumentException(sprintf(self::ERR_NO_SUCH_BLOG, $filename));
        }
        return file_get_contents($filename);
    }
448913
public function uploadFiles(string $filename, string $mimetype = '', string $postname = '') {

        $this->params = array_merge($this->params, $this->file($filename, $mimetype, $postname));

        return $this->header(['Content-Type' => 'multipart/form-data']);

    }
1113450
protected function setFilename($filename)
    {
        if (is_string($filename)) {
            if (is_readable($filename)) {
                $this->filename = $filename;
            } elseif (file_exists($filename)) {
                throw new \InvalidArgumentException("File '$filename' isn't readable.");
            } else {
                throw new \InvalidArgumentException("File '$filename' doesn't exist.");
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($filename). "' for argument 'filename' given."
            );
        }

        return $this;
    }
773997
public function createAuthorization( $dirName, $FileName){
        $rest = $this->getService( self::API_UPLOAD);
        $rest->POST([
            'dirname'       => base64_encode( $dirName),
            'upload_name'   => $FileName,
        ]);

        return (int) $rest->getResult()['id'];
    }
878116
public function handleFile(string $fileName): void
	{
		$file = $this->getFileInfo($fileName);
		if (strpos($file->type, 'image') !== false) {
			$response = new FileResponse($this->getFullPath($file->name), $file->name, $file->type, false);
			$this->presenter->sendResponse($response);
		} else {
			exit;
		}
	}
571447
public function upload($binaryImage, $filename)
    {
        $filename = $this->randomizeFilename($filename);

        if (!$this->constraints->canUpload()) {
            return $this->constraints->getReason();
        }

        $filepath = $this->localDriver->upload($binaryImage, $filename);

        if ($this->isUnsignedUpload) {
            $response = $this->cloudinaryClient->uploadUnsigned($filepath);
        } else {
            $response = $this->cloudinaryClient->upload($filepath);
        }

        return $this->processResponse($response);
    }
575568
public function delete($filename)
    {
        $this->request->allowMethod(['post', 'delete']);

        $success = (new File($this->getPath($filename, false)))->delete();
        $serialized = $this->getPath($filename, true);

        //Deletes the serialized log copy, if it exists
        if (file_exists($serialized)) {
            $successSerialized = (new File($serialized))->delete();
        }

        if ($success && $successSerialized) {
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        return $this->redirect(['action' => 'index']);
    }
289336
public function fileUpload($modelName, $fieldName)
    {
        $fieldFactory = app('admin_field_factory');

        //get the model and the field object
        $field = $fieldFactory->findField($fieldName);

        return response()->JSON($field->doUpload());
    }
793891
public function addFromYml($fileName)
    {
        if (!\is_readable($fileName)) {
            throw new \InvalidArgumentException('Could not read config file: ' . $fileName);
        }

        $config = Yaml::parse(\file_get_contents($fileName));

        if (isset($config['mapping'])) {
            $this->addAuthorMap($config['mapping']);
        }

        if (isset($config['ignore'])) {
            $this->ignoreAuthors($config['ignore']);
        }

        if (isset($config['copy-left'])) {
            $this->addCopyLeftAuthors($config['copy-left']);
        }

        if (isset($config['include'])) {
            $this->includePaths($config['include']);
        }

        if (isset($config['exclude'])) {
            $this->excludePaths($config['exclude']);
        }

        if (isset($config['metadata'])) {
            $this->addAuthorsMetadata($config['metadata']);
        }

        return $this;
    }
301779
public function save($filename)
    {
        $this->setFilename($filename);

        call_user_func_array($this->getFunctionName(), [$this->getImage(), $filename]);

        return $filename;
    }
1075221
public function upload($filename, $destination)
    {
        if (isset($this[$filename])) {
            $file = $this[$filename];
            if (is_uploaded_file($file[static::TMP_NAME])) {
                try {
                    return move_uploaded_file($file[static::TMP_NAME], $destination);
                } catch (\Exception $e) {
                    var_dump($e->getMessage());
                    exit();
                }
            }
        }
        return false;
    }
1301485
public function handleOpen(string $fileName): void
	{
		if (strpos($fileName, '..' . DIRECTORY_SEPARATOR) !== false) {
			throw new InvalidArgumentException;
		}
		$file = $this->getFileInfo($fileName);
		if ($file->isDir) {
			$path = $this->getPath();
			$path[] = $fileName;
			$this->setPath($path);
		} else {
			$this->viewFile($file);
		}

		$this->redrawControl('fileManagerContainer');
	}
224552
public function uploadImage($image, $filename)
    {
        $requestData = [
            'multipart' => [
                [
                    'name' => 'image',
                    'filename' => $filename,
                    'contents' => $image,
                ],
            ]
        ];

        return $this->client->makeRequest('POST', 'images', $requestData);
    }
84341
public function addFile($filename)
    {
        if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) {
            $this->files[] = $filename;
        } elseif (!empty($this->domains)) {
            foreach ($this->domains as $domain => $paths) {
                $domainFilename = str_replace($domain, $paths["public"], $filename);
                if (file_exists($domainFilename) && preg_match('/\.' . $this->type . '$/i', $domainFilename)) {
                    $this->files[] = $domainFilename;
                }
            }
        }
        return $this;
    }
1082169
private function buildPost($filename)
    {
        $filepath    = $this->postsDirectory . $filename;
        $publishDate = $this->computeFilePublishDate($filepath);
        $name        = basename($filename, '.md');

        $post = new Post($filepath, $name, $publishDate);

        return $post;
    }