Hi there,
im trying to add images to a page. The data is send via ajax to the php.
The php gets the local image urls. They look like:
data:image/png;base64,iVBORw0KGgo...
Now i try to write the images to to page like this:
foreach ($item_images as $image) {
$p->images->add($image);
}
Where $item_images is a array send via js with the local image urls.
This causes a Error: <b>Fatal error</b>: Call to a member function add() on null in ...
So im unsure if images->add expects another data format than this local image url (see above).
Or im doing somthing wrong or this is totaly wrong and i have to use WireUpload?. Full php:
<?php
require_once '../index.php';
$item_titel = $_GET["item_titel"];
$item_client = $_GET["item_client"];
$item_date = $_GET["item_date"];
$item_usecase = $_GET["item_usecase"];
$item_images = $_GET["item_images"];
$item_text = $_GET["item_text"];
$targetPage = "/items/";
$p = new Page();
$p->template = 'item';
$p->parent = wire('pages')->get($targetPage);
$p->title = $item_titel;
$p->item_titel = $item_titel;
$p->item_client = $item_client;
$p->item_date = $item_date;
$p->of(true);
foreach ($item_images as $image){
$p->images->add($image);
// $image looks like: data:image/png;base64,iVBORw0KGgo...
}
$p->item_text = $item_text;
$p->save();
$p->of(false);
Any help is very much appreciated .)
cheers Simon