Skip to content

Instantly share code, notes, and snippets.

@mipapo
Last active April 12, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipapo/cafe45b0c2a247d9c0614bd2cc8fe4d0 to your computer and use it in GitHub Desktop.
Save mipapo/cafe45b0c2a247d9c0614bd2cc8fe4d0 to your computer and use it in GitHub Desktop.
Runalyze Upload fast API
<?php
#call/upload.php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
require_once '../inc/class.Frontend.php';
$Frontend = new Frontend(true);
System::setMaximalLimits();
if(count($_FILES) == 1) {
$filename = 'api'.uniqid().$_FILES['fileUpload']['name'];
move_uploaded_file($_FILES['fileUpload']['tmp_name'], '../data/import/'.$filename);
$Factory = new ImporterFactory($filename);
foreach ($Factory->trainingObjects() as $training) {
$training->insert();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment