Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2020 06:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
// This is dangerous, I would never do this.
// Just for testing purposes:
$_SESSION['loggedin'] = true;
use Imanager\Category;
use Imanager\Field;
use Imanager\FieldConfigs;
use Imanager\FieldFileupload;
use Imanager\Item;
include '../framework/imanager.php';
$gallery = $imanager->getCategory('name=Gallery');
$timestamp = time();
$item = $gallery->getItem(1);
if(!$item) {
$item = new Item($gallery->id);
if($imanager->input->post->action == 'save') {
$dataSent = array(
'file' => $imanager->input->post->position_images,
'title' => $imanager->input->post->title_images,
'timestamp' => $imanager->input->get->timestamp
// Set input value
if($item->set('images', $dataSent)) {
} else {
echo 'Error: The field value could not be set';
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="description" content="Just a simple login Form">
<!-- Mobile-friendly viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
<meta name="author" content="J.E">
<main role="main">
$imanager->fieldMapper->init($gallery->id, true);
$field = $gallery->getField('name=images');
$widget = new FieldFileupload;
// Action should point to the processing script,
// in our case it is the same file "index.php":
echo '<form action="./" method="post">';
// The widget's parameter "url" points to the IM root,
// in our case "../framework/" (Note trailing slash):
$widget->set('url', '../framework/');
// The widget's action points to the upload processor:
$widget->set('action', "../framework/imanager/upload/server/php/index.php");
$widget->set('id', $field->name);
$widget->set('categoryid', $field->categoryid);
$widget->set('itemid', isset($item->id) ? $item->id : null);
$widget->set('timestamp', $timestamp);
$widget->set('fieldid', $field->id);
$widget->set('configs', $field->configs, false);
$widget->set('name', $field->name);
echo $widget->render();
echo '<input type="hidden" name="action" value="save">';
echo '<button type="submit">Save</button>';
echo '</form>';
<footer role="contentinfo">
<small>Copyright &copy;
<time datetime="<?php echo date('Y'); ?>"><?php echo date('Y'); ?></time> Ehret Studio</small>
<script src=""></script>
<script src=""></script>
<?php echo $widget->renderJsBlock(); ?>
<?php echo $widget->renderJsLibs(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment