我想在ASP.NETWebService.asmx
中创建一个Web服务以添加图像,因此我添加了fileUpload
string uploadImage(FileUpload file_upload_control, int order_id)
{
string path = Server.MapPath($"/orders_images/");
string directory = Path.Combine(path, order_id.ToString());
Directory.CreateDirectory(directory);
string file = "";
if (file_upload_control.HasFile)
{
file = System.IO.Path.Combine(directory, file_upload_control.FileName);
file_upload_control.SaveAs(file);
}
string file_name = file_upload_control.FileName;
return file_name;
}
[WebMethod]
public string add_image(string curomer_name,FileUpload customer_image)
{
string str_curomer_name = curomer_name;
string str_customer_image = uploadImage(customer_image, 10);
return "ok";
}
但我得到了这个error
我该怎么解决这个问题?
1条答案
按热度按时间ru9i0ody1#
通过研究问题,Web服务使用字节数据类型将图像或文件保存在物理驱动器中,例如上面的代码
使用byte[]文件上载控制而不是文件上载文件上载控制