我正在努力上传并将该图像的缩略图副本保存在缩略图文件夹中.
我正在使用以下链接:
http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx
但
newBMP.Save(directory + "tn_" + filename);
Run Code Online (Sandbox Code Playgroud)
导致异常"GDI +中发生了一般错误."
我试图给予文件夹权限,还试图在保存时使用新的单独的bmp对象.
编辑:
protected void ResizeAndSave(PropBannerImage objPropBannerImage)
{
// Create a bitmap of the content of the fileUpload control in memory
Bitmap originalBMP = new Bitmap(fuImage.FileContent);
// Calculate the new image dimensions
int origWidth = originalBMP.Width;
int origHeight = originalBMP.Height;
int sngRatio = origWidth / origHeight;
int thumbWidth = 100;
int thumbHeight = thumbWidth / sngRatio;
int bannerWidth = 100;
int bannerHeight = bannerWidth / sngRatio;
// Create a new …Run Code Online (Sandbox Code Playgroud) 我正在向数据库添加日期和图像.我想将日期作为页脚添加到上传的图像.
用于图像的HTML upload
<div class="form-group">
@Html.Label("Photo", htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
<img id="DocImg" src="~/Upload/DoctorImage/doc-default.png" style="cursor: pointer;" accesskeyclass="edtImg" width="100" height="100" />
<input type="file" id="fileUpload" name="Photo" accept="image/*" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
HTML for datepicker
<div class="col-6">
@Html.ValidationSummary(true, "", new { @class = "text-danger"})
<div class="form-group">
@Html.Label("Joining Date", htmlAttributes: new { @class = "control-label col-md-2", @required = "required" })
<div class="col-md-10">
@(Html.Kendo().DatePicker()
.Name("JoiningDate")
.Value("")
.HtmlAttributes(new { style = "width: 100%", required = "true" })
)
@Html.ValidationMessageFor(model => model.JoiningDate, "", new …Run Code Online (Sandbox Code Playgroud)