0

I am using adobe creative sdk image editor and .net for my project. When I edit a image, only <"img"> is changing but I am sending <"input file">. I tried two way, firstly I send data to <"input file"> and later send to controller. But I didnt. Secondary directly <"img"> file to controller but again didnt work.`

Index

@using (Html.BeginForm("Save", "Tweet", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>TweetModel</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
            </div>
        </div>
    </div>



    <div class="row">
        <div class="col-md-10">
            <input id="click-upload" name="file" type="file">
            <div id="drop-area">
                <p>Drop an image here!</p>
                <p>(or click to upload)</p>
            </div>
            <img id="editable-image" onclick="read()" class="img-responsive">
        </div>
    </div>
            <div class="col-md-12">
                <button>Gönder</button>
            </div>
}`


 <script type="text/javascript">
    function read()
    {
        var c = document.getElementById("editable-image");
        document.getElementById("click-upload").innerHTML = c;
        alert(document.getElementById("click-upload").size);
    }

    </script>

public ActionResult Save(Tweet tweetModel)
    {
        WebImage file = WebImage.GetImageFromRequest();
        tweetModel.UserId = Convert.ToInt32(Session["UserId"]);
        if (tweetModel.UserId > 0)
        {
            if (file.FileName !=null)
            {

                // code for saving the image file to a physical location.
                var fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Uploads/Image"), fileName);
                file.Save(path);
                // prepare a relative path to be stored in the database and used to display later on.
                path = Url.Content(Path.Combine("~/Uploads/Image", fileName));
                // save to db
                tweetModel.Image = path;

            }

            CreateOrder(tweetModel);
        }
        return RedirectToAction("Index");
    }
Deniz Ozogul
  • 85
  • 11
  • we can't fix code we can't see.... – ADyson Jun 21 '18 at 07:32
  • As far as I know the content of an `input type="file"` must be a file chosen by the user, from their disk. You cannot insert another HTML element into it like that - a HTML element isn't a file, for a start. Did you get this idea from some tutorial, or was it your own idea? It cannot work like that. Is there no documentation produced by Adobe about how to get the contents of the file from the editor? – ADyson Jun 21 '18 at 07:51
  • @ADyson That's my idea. I dont have any documentation. I thought like you but second idea probably will work. I could not write true code :/ – Deniz Ozogul Jun 21 '18 at 08:01

0 Answers0