我使用dropzonejs可以将图像保存在文件夹中,是否有可能将其保存为asp图像,这样我就可以将其插入数据库了!
这是我的httprequest “ context.Response.ContentType =” image / plain“;
string dirFullPath = HttpContext.Current.Server.MapPath("~/image/");
string[] files;
int numFiles;
files = System.IO.Directory.GetFiles(dirFullPath);
numFiles = files.Length;
numFiles = numFiles + 1;
string str_image = "";
foreach (string s in context.Request.Files)
{
HttpPostedFile file = context.Request.Files[s];
string fileName = file.FileName;
string fileExtension = file.ContentType;
if (!string.IsNullOrEmpty(fileName))
{
fileExtension = Path.GetExtension(fileName);
str_image = numFiles.ToString() + fileExtension;
string pathToSave = HttpContext.Current.Server.MapPath("~/image/") + str_image;
file.SaveAs(pathToSave);
}
}
context.Response.Write(str_image);
”