2

I've no clue how impresspages uploads images. I've tried many of the function but did not succeeded yet.

    $("#choose_image").on('change',function(e){
    var data = {
        'aa' : 'InlineManagement.customImageSave',
        'securityToken' : $('input[name=securityToken]').val(),
        'image' : JSON.stringify($(this)[0].files)
    };
    $.ajax({
        url : ip.baseUrl,
        type : 'POST',
        dataType : 'Json',  
        data : data,
    })
    .done(function() {
        console.log("success");
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });
});

AdminController

public function customImageSave()
{   
    ipRepositoryAddFile(json_decode($_POST['image']));
    return new \Ip\Response\Json(array('Sucess' => 'Image added successfully'));
}

I get the following error when I use ipRepositoryAddFile

 Uncaught exception 'Ip\Exception' with message 'File doesn't exist' in 
 D:\xampp\htdocs\ImpressPages\Ip\Internal\Repository\Model.php:118

1 Answers1

1

The function ipRepositoryAddFile($file, [ null|string $desiredName ] ) requires a path to the file where $file is the absolute path to the temp directory.

Not exactly sure what you're trying to do though. Are you trying to re-invent the wheel here creating your custom upload method?

There are a few options in impresspages to upload files/images. You could use a form object https://www.impresspages.org/docs/form-object/repositoryfile or the Repository it self https://www.impresspages.org/docs/repository