Javascript 在c#中使用jquery ajax将图像保存到文件夹中?

Javascript 在c#中使用jquery ajax将图像保存到文件夹中?,javascript,c#,jquery,ajax,Javascript,C#,Jquery,Ajax,我可以在.cs页面上发送数据,图像也保存在文件夹中,但它已损坏,图像大小为0。。我完全不知道错误在哪里 请参见JQUERY代码和C代码 JQUERY代码 <script type="text/javascript"> $(document).ready(function () { $("#submitPhoto").click(function () { var photo = $("#uploadPhoto").get(0);

我可以在.cs页面上发送数据,图像也保存在文件夹中,但它已损坏,图像大小为0。。我完全不知道错误在哪里 请参见JQUERY代码和C代码

JQUERY代码

<script type="text/javascript">
    $(document).ready(function () {
        $("#submitPhoto").click(function () {
            var photo = $("#uploadPhoto").get(0);
            var file = photo.files;
            var Photo_Path = $("#uploadPhoto").val();
            var extenssion = Photo_Path.split('.').pop().toUpperCase();
            if (Photo_Path == "") {
                alert('Please Choose Photo');
                return;
            }

            if (extenssion != 'JPEG' && extenssion != 'JPG' && extenssion != 'jpg') {
                alert('Invalid File[JPEG,JPG is acceptable]');
                return;
            }
            if (file.size < 4000 || file.size > 14000) {
                alert('Photo Size Must be Below 12Kb and Above 4Kb ');
                return;
            }
            var id = $("#submitPhoto").attr('id');                

            $.ajax({
                type: "POST",
                contentType: "multipart/form-data",
                url: "finalstep-registration.aspx?photoPath=" + Photo_Path + "&id=" + id + "&check=imgUpload",
                data: file,
                datatype: 'json',
                async: false,
                processData: false,
                success: function (data) {

                    alert('Image successfully Uploaded');

                },
                error: function ()
                { console.log('there is some error'); }
            });
        });
 </script>

检查并告诉我哪里做错了

Photo_Path.split('.').pop().toUpperCase()?为什么弹出它将更新错误的路径我正在使用它检查扩展名,仅此而已,我正在发送ajax数据变量中的图像索引。。
public void uploadPhoto(string photoPath,string id)
{
    //HttpContext context = HttpContext.Current;        
    //int regNo = Convert.ToInt32(Session["restrationNumber"].ToString());
    int regNo = 1001;

    if (id == "submitPhoto")
    {
        FileInfo CustPic = new FileInfo(photoPath);
        System.IO.Stream fileContent = Request.InputStream;
        FileStream fileStream = File.Create(Server.MapPath("~/photo/") + CustPic.Name);
        fileContent.Seek(0, System.IO.SeekOrigin.Begin);
        fileContent.CopyTo(fileStream);
        //System.Web.Hosting.HostingEnvironment.MapPath("~/photo/");            
        string query = "update userDetails set photo='"+photoPath+ "' where regNo="+regNo+"";
        int a = bl.executenonquery(query);
        if (a == 1)
            Response.Write("Photo is uploaded successfully");
        else
            Response.Write("Oops, We can't upload your photo. try again");

        //Session["photo"] = CustPic.Name;

    }
}