Upload the file to the server

@param $request
@param $file
@param $filename
761702
public function handleFile($request, $file, $filename)
    {
        $filesystem = new FileFieldUploadService([
            'file' => $file,
            'filename' => $filename,
            'upload_to' => $this->getUploadTo(),
        ]);

        // Write the image to the file system and move it in place
        $filesystem->write();
    }
266469
public static function file(File $file, $filename = null, $mime = null) {

		if(null !== $filename && false === is_string($filename)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($filename)), E_USER_ERROR);
		}

		if(null !== $mime && false === is_string($mime)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mime)), E_USER_ERROR);
		}

		if(null !== $file -> entity()) {

			//Determine file name
			$filename = null !== $filename ? $filename : $file -> entity() -> getBasename();

			//Add mime if known
			$mime = null !== $mime ? $mime : $file -> getMime();

			if(null !== $mime) {
				static :: addHeader('Content-Type', $mime);
			}

			static :: addHeader('Content-Transfer-Encoding', 'binary');
			static :: addHeader('Expires', '0');
			static :: addHeader('Pragma', 'public');
			static :: addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
			static :: addHeader('Content-Length', $file -> entity() -> getFilesize());
			static :: addHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
			static :: addHeader('Expires', 'Tue, 25 Oct '. (date('Y') - 10) .' 05:00:00 GMT');
			static :: addHeader('Pragma', 'no-cache');

			if($fd = @fopen($file -> entity() -> getBasepath(), 'r')) {

				ob_clean();
				flush();

				while(!feof($fd)) {
					echo fread($fd, 2048);
				}
				
				fclose($fd);
			}
		}
	}
775468
public static function createUploadedFile(
        $file,
        $size = null,
        $error = UPLOAD_ERR_OK,
        $clientFilename = null,
        $clientMediaType = null
    ) {
        if (! static::$uploadedFileFactory) {
            static::$uploadedFileFactory = new UploadedFileFactory();
        }

        return static::$uploadedFileFactory->createUploadedFile(
            $file,
            $size,
            $error,
            $clientFilename,
            $clientMediaType
        );
    }
1039174
public function update(FileRequest $request, File $file)
    {
        $file->update($request->all());
        
        return $this->makeRedirect(true, 'admin.files.index', __('msg.update'));
    }
764625
public function upload($file, $destination = null)
    {
        if (!file_exists($file)) {
            return;
        }

        // Get contents and destination
        $destination = $destination ?: basename($file);

        $this->put($destination, file_get_contents($file));
    }
624045
public function upload(File $file,$category,$name=""){
      return  $this->storage->upload($file,$category,$name);
    }
56582
public function upload(Request $request)
    {
        try {
            $realPath = Storage::disk($this->filesystem)->getDriver()->getAdapter()->getPathPrefix();

            $allowedImageMimeTypes = [
                'image/jpeg',
                'image/png',
                'image/gif',
                'image/bmp',
                'image/svg+xml',
            ];

            if (in_array($request->file->getMimeType(), $allowedImageMimeTypes)) {
                $file = $request->file->store($request->upload_path, $this->filesystem);

                $image = Image::make($realPath.$file);

                if ($request->file->getClientOriginalExtension() == 'gif') {
                    copy($request->file->getRealPath(), $realPath.$file);
                } else {
                    $image->orientate()->save($realPath.$file);
                }
            } else {
                $file = $request->file->move($realPath, $request->file->getClientOriginalName());
            }

            $success = true;
            $message = __('admin.media.success_uploaded_file');
            $path = preg_replace('/^public\//', '', $file);
        } catch (Exception $e) {
            $success = false;
            $message = $e->getMessage();
            $path = '';
        }

        return response()->json(compact('success', 'message', 'path'));
    }
543289
public function upload(Request $request)
    {
        $validation = $this->validation->check([
            'location' => [],
        ]);

        if (!$validation['errors']) {
            $file = $request->file('location');
            $fileSaved = $this->fileService->saveFile($file, 'files/');
            $fileSaved['name'] = CryptoService::encrypt($fileSaved['name']);
            $fileSaved['mime'] = $file->getClientMimeType();
            $fileSaved['size'] = $file->getClientSize();
            $response = $this->responseService->apiResponse('success', $fileSaved);
        } else {
            $response = $this->responseService->apiErrorResponse($validation['errors'], $validation['inputs']);
        }

        return $response;
    }
787844
public function handleUpload(\Illuminate\Http\Request $request, $fieldname = 'photo', $folder = 'images', $storage_disk = 'public', $randomize = true){
        if(is_null($request->file($fieldname)) || !$request->file($fieldname)->isValid()){
            throw new \Exception(trans('crud.invalid_file_upload'));
        }
        //Get filename
        $basename = basename($request->file($fieldname)->getClientOriginalName(),'.'.$request->file($fieldname)->getClientOriginalExtension());
        if($randomize){
            $filename = uniqid().'_'.str_slug($basename).'.'.$request->file($fieldname)->getClientOriginalExtension();
        }
        else{
            $filename = str_slug($basename).'.'.$request->file($fieldname)->getClientOriginalExtension();
        }
        //Move file to location
        $request->file($fieldname)->storeAs($folder,$filename,$storage_disk);
        return $filename;
    }
625904
public function uploadFile(string $file, string $path, string $name)
    {
        // to store the file we have to make sure the directory exists
        foreach ($this->extractDirectories($path) as $dir) {
            // if change to directory fails
            // create the dir and change into it afterwards
            try {
                $this->chDir($dir);
            } catch (\Exception $e) {
                $this->mkDir($dir);
                $this->chDir($dir);
            }
        }
        if (!$this->put($name, $file, FTP_BINARY)) {
            $error   = error_get_last();
            $message = $error['message'];
            throw new RuntimeException(sprintf('error uploading file: %s - %s', $file, $message));
        }
    }
613793
public function upload($filename, $type = 'icon')
    {
        $url = "https://api.weixin.qq.com/shakearound/material/add?access_token=ACCESS_TOKEN&type={$type}";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)]);
    }
415956
private function handleUploadFiles(Request $request, $namespace, $files = null)
    {
        $filesToProcess = $this->getFilesToProcess($request, $namespace, $files);

        /** @var \Sirius\Upload\Result\Collection $result */
        $result = $this->app['upload']->process($filesToProcess);

        if ($result->isValid()) {
            if (!$this->app['config']->get('general/upload/autoconfirm')) {
                // Remove the .lock file attached to the file
                $result->confirm();
            }

            $successfulFiles = [];
            foreach ($result as $resultFile) {
                $successfulFiles[] = $this->filesystem()->toJs($namespace . '://' . $resultFile->name);
            }

            return $successfulFiles;
        }

        // The file that was saved during process() has a .lock file attached
        // and can now be cleared, in the case where form processing fails
        try {
            $result->clear();
        } catch (\Exception $e) {
            // It's an error state anyway
        }

        $errorFiles = [];
        foreach ($result as $resultFile) {
            $errors = $resultFile->getMessages();
            $errorFiles[] = [
                    'name'  => $resultFile->original_name,
                    'error' => (string) $errors[0],
                ];
        }

        return $errorFiles;
    }
1340022
public static function upload(String $fileName = 'upload', String $rootDir = UPLOADS_DIR) : Bool
    {
        return Upload::start($fileName, $rootDir);
    }
891633
public function get_file(Request $request)
    {
        $filepath = $request->input('filepath');
        $data = file_get_contents(base_path($filepath));
        echo $data;
    }
1184639
public function uploadFileAction(Request $request)
    {
        /** @var FormBuilderInterface $uploadForm */
        $form = $this->createForm(TranslationsFileUploadType::class);
        $configurator = $this->getAdminListConfigurator();

        if (Request::METHOD_POST === $request->getMethod()) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $locales = $this->getParameter('kuma_translator.managed_locales');
                $data = $form->getData();
                $file = $data['file'];
                $force = $data['force'];
                $imported = $this->container->get('kunstmaan_translator.service.importer.importer')->importFromSpreadsheet($file, $locales, $force);
                $this->addFlash(FlashTypes::SUCCESS, sprintf('Translation imported: %d', $imported));
            }
        }

        return [
            'form' => $form->createView(),
            'adminlistconfigurator' => $configurator,
        ];
    }
781342
public function put($filename, $content)
    {
        // Merge existing content to new content
        if (file_exists($this->cacheDir . $filename) && file_get_contents($this->cacheDir . $filename) != '') {
            $cachedContent = $this->get($filename);
            $content       = array_merge($content, $cachedContent);
        }
        $this->files->put($this->cacheDir . $filename, json_encode($content));
    }
224552
public function uploadImage($image, $filename)
    {
        $requestData = [
            'multipart' => [
                [
                    'name' => 'image',
                    'filename' => $filename,
                    'contents' => $image,
                ],
            ]
        ];

        return $this->client->makeRequest('POST', 'images', $requestData);
    }