is changing but I am sending <"input file">. I t" /> is changing but I am sending <"input file">. I t" /> is changing but I am sending <"input file">. I t"/>

Send img file to .net controller from <"img">

38 views Asked by At

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");
    }
0

There are 0 answers