使用Ajax将文件发布到服务器

I use ajax post method to send Image to server.

Is it normal Page_Load event fires when post method is called ?

Don't need to write [WebMethod] for this ?

By writting below code on Page_Load I can get Image from ajax:

       HttpFileCollection filesColl = Request.Files;
        foreach (string uploader in filesColl)
        {
            HttpPostedFile file = filesColl[uploader];
            if (file.ContentLength > 0)
            {
                SavePhotoDatabase.SaveCVPhoto(file);
            }
        }

Is it good idea or I should wirte [WebMethod]?

查看全部
weixin_33739523
weixin_33739523
2014/06/20 12:39
  • c#
  • upload
  • asp.net
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

0个回复