I'm currently trying to upload a file to Parse following the posting of a form with the Slim framework. For some reason I get the file name, but can't actually get the file with my current setup. I've also tried looking for the $_FILES
array, but nothing is coming across. Is there something I'm missing? Here's my current route:
$app->group('/settings', function () use ($app) {
$app->post('/update(/:settingsId)', function ($settingsId = null) use ($app) {
$query = new ParseQuery("Settings");
// Get a specific object:
$settings = $query->get($settingsId);
// Set values:
$settings->set("appName", $app->request->post('appName'));
$settings->set("directorName", $app->request->post('directorName'));
$settings->set("mkUsername", $app->request->post('mkUsername'));
$settings->set("mkPassword", $app->request->post('mkPassword'));
error_log(print_r($_FILES, true));
// see if we have a file
if ($app->request->post('appBackgroundImage')) {
// save file to Parse
$appBackgroundImage = ParseFile::createFromData(file_get_contents($_FILES["file"]["tmp_name"]), $app->request->post('appBackgroundImage'));
$appBackgroundImage->save();
$settings->set("appBackgroundImage", $appBackgroundImage);
}
try {
$settings->save();
$app->redirect('/settings');
} catch (ParseException $ex) {
$app->redirect('/settings/' . $ex->getCode());
}
});
});