如何将参数从弹出提交传递到刷新iframe

时间:2017-03-07 06:07:27

标签: javascript jquery html iframe popup

如何从带有捕获照片的弹出窗口传递数据并将其传递给在捕获照片弹出窗口关闭时重新加载的iframe?

这是情景:

我有一个带有iframe的页面,可以打开捕获照片的弹出窗口。我想要的只是将拍摄的照片传输到父iframe,这样当我保存iframe所在页面的形式时,我可以同时保存拍摄的照片。

继承我的代码:

在我的iframe中:

<div class="ibox-content">
    <div class="form-group">
        @Html.LabelFor(model => model.CarImage, new { @class = "control-label col-md-2 required" })
        <div class="col-md-10">
            <input type="file" name="CarImage" id="CarImage" />
            @Html.ValidationMessageFor(model => model.CarImage, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <a class="linkCaptureOpener button_back button_example_small" href="@Url.Action("CapturePhoto", "Vehicle", new { area = "Homeowner" , id = userId })">
            Take a Photo
        </a>
    </div>
</div>

这是我转换图片的捕获照片的保存事件。有了这个,我试图使用RedirectToAction作为参数传递图像,但它只在弹出窗口中打开iframe。

[HttpPost]

public ActionResult CapturePhoto(VehicleViewModel model, string imageConverted,int id) {

    try {
        byte[] dataImage;
        string fileName = string.Empty;

        DirectoryInfo dir2 = new DirectoryInfo(Server.MapPath("~/CreateImage"));
        if (!dir2.Exists) {
            dir2.Create();
        }

        fileName = "CARIMAGE" + DateTime.Now.ToString("yyyyMMddTHHmmss") + ".jpg";
        string fileNameWitPath = Path.Combine(Server.MapPath("~/CreateImage"), fileName);

        using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create)) {
            using (BinaryWriter bw = new BinaryWriter(fs)) {
                dataImage = Convert.FromBase64String(imageConverted);
                bw.Write(dataImage);
                bw.Close();
            }
            fs.Close();
        }

        var checkData = dataImage;

        return RedirectToAction("GetCarImage", new {filename = fileName });

    } /*END try*/

    catch (Exception ex) {

    }

    return View(model);
} /*END CapturePhoto*/

0 个答案:

没有答案