You are here

public function SmartImporterFileUploadController::uploadFile in Commerce Smart Importer 8

Handles uploaded files.

1 string reference to 'SmartImporterFileUploadController::uploadFile'
commerce_smart_importer.routing.yml in ./commerce_smart_importer.routing.yml
commerce_smart_importer.routing.yml

File

src/Controller/SmartImporterFileUploadController.php, line 65

Class

SmartImporterFileUploadController
File upload handler.

Namespace

Drupal\commerce_smart_importer\Controller

Code

public function uploadFile(Request $request) {
  $image = $request->files
    ->get('file');
  if (!is_dir(CommerceSmartImporterConstants::TEMP_DIR)) {
    mkdir(CommerceSmartImporterConstants::TEMP_DIR);
  }
  $image
    ->move($this->fileSystem
    ->realpath(CommerceSmartImporterConstants::TEMP_DIR) . '/', $image
    ->getClientOriginalName());
  return new Response('Uploaded successfully');
}