gpt4 book ai didi

javascript - 如何在 asp classic 中使用 jquery 将图像保存在我的服务器中?

转载 作者:行者123 更新时间:2023-12-03 03:34:39 24 4
gpt4 key购买 nike

我需要保存用户上传的图像。我已经有 Base64 字符串形式的文件并已在 FileReader var 中,如何将其保存在文件夹中?

Jquery 代码:

$("#picture").on('change',function(){ 
var file = $(this)[0].files[0];
var fr = new FileReader();
fr.onload = function () {
$('.frame-image').css('background-image', "url('"+fr.result+"')");
}
fr.readAsDataURL(file);
});

HTML

<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label>Imagem</label>
<input class="form-control" type="file" name="picture" id="picture" />
</div>
</div>
</div>
<div class="frame-image" style="background-image: url('../img/frames/placeholder-square.svg');">
</div>

最佳答案

您可以使用$.post将变量的内容发送到服务器:

$.post("path/to/save.asp", { imagestring : fr.readAsText() });

在服务器端,您将从表单中检索图像字符串值,并将其保存到文件中。 (您需要尝试不同的格式和转换选项,直到获得正确保存的内容。

字符串数据 = Request.Form("imagestring");

使用FileSystemObject保存文件。

抱歉缺少代码;我已经很久没有需要使用经典 ASP 了。

关于javascript - 如何在 asp classic 中使用 jquery 将图像保存在我的服务器中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45922037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com