Can not Upload image by Inline Editor

Helen Tran asked on March 2, 2022 04:48

Hi guys, I am trying to use Inline Editor to upload an image (only 6 KB) from my device local but its response failed with the status "Server responded with 0 code".

This is my code below:

ImageUploaderEditorViewModel : InlineEditorViewModel

public string GetDataUrl()
{
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
if (ImageType == ImageTypeEnum.Attachment)
{
    return urlHelper.Kentico().AuthenticateUrl(urlHelper.Action("Upload", "ImageUploader", new{
        pageId = HttpContext.Current.Kentico().PageBuilder().PageIdentifier
    }), false).ToString();
}

if (ImageType == ImageTypeEnum.MediaFile)
{
    return urlHelper.Kentico().AuthenticateUrl(urlHelper.Action("Upload", "MediaFileImageUploader",new{
    libraryName = MediaLibraryName
}), false).ToString();
}

return null;
}

**_ImageUploaderEditor.cshtml**

@using (Html.Kentico().BeginInlineEditor("image-uploader-editor", Model.PropertyName,
new
{
    @class = "image-uploader-editor",
    data_url = Model.GetDataUrl(),
    data_file_type = Model.ImageType == ImageTypeEnum.MediaFile ? "media" : "attachment"
}))
{
<div class="@GetContainerClass()">
    <div class="uploader">
        <div class="dz-message @GetMessagePositionClass()">
            <i class="icon-arrow-up-line"></i>
            <div>
               @Model.TextMessage <a class="dz-clickable">click</a> to browse
            </div>
        </div>
    </div>
</div>
}

I am not sure there is anything wrong here or if I missed any config. Can anyone have an idea what is the issue I get?

Recent Answers


Dmitry Bastron answered on March 3, 2022 16:43

Hi Helen,

I guess you have taken this implementation from the DancingGoat demo website, haven't you? In debug, can you attach to MediaFileImageUploaderController and see if the request comes through and how it is processed? Are there any errors during its execution?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.