本文介绍了从jquery到codebehind时,fileupload postedfile为null.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好Iam yogesh sharma iam在从HTML输入文件中保存发布文件时遇到问题
放入某个文件夹...
我必须使用jquery获取html输入文件的PostFile,然后使用webmethod将其从后台代码保存到某个文件夹中.我的问题是,当我检查
通过调试我在webmethod中的文件,我将发布文件设为NULL.我得到的是该文件的大小,可以.但是postfile为null..
我的Jquery代码是.....

Hi Iam yogesh sharma iam having problems in saving the postedfile from HTML input file
into some folder...
I Have to get the PostedFile of html input file using jquery and save that file into some folder from codebehind using webmethod. my problem is that when i checked the
file in webmethod by debugging i get the postedfile as NULL. I am getting the size of that file which is OK.But postedfile is null..
My Jquery Code Is.....

function SubmitImage_Click() {
                   var postedfile = ($("#fupdImg"))[0].files[0];
                   //alert(postedfile);
                   var exist = $("#fupdImg").val().split('.').pop();
                   PageMethods.GetNewImageName(exist, postedfile);                     
And My Code behind is....
<pre lang="c#">
[System.Web.Services.WebMethod()]
    [System.Web.Script.Services.ScriptMethod()]
    public static void GetNewImageName(string extension,HtmlInputFile file)
    {
        clsMNC obj = new clsMNC();
        string ssql = "select Count(ProductId)+1 from Product";
        Int32 pid = Convert.ToInt32(obj.getOneValue(ssql));
        string imgName = "img" + "_" + pid +"."+ extension;
        //return imgName;
        string savepath = HttpContext.Current.Server.MapPath(".") + "\\UserImgs\\";
        savepath += imgName;
        hp=file.PostedFile;



在这里我想使用SaveAs方法保存file.postedfile ...
请帮忙,我正在尝试2天以来,但没有收到google的答复.
任何帮助将不胜感激...



Here I want to save file.postedfile using SaveAs Method...
Please help, I am Trying Since 2 days but not getting answer from google..
Any Help wiil be appreciated...

推荐答案




在这里我想使用SaveAs方法保存file.postedfile ...
请帮忙,我正在尝试2天以来,但没有收到google的答复.
任何帮助将不胜感激...



Here I want to save file.postedfile using SaveAs Method...
Please help, I am Trying Since 2 days but not getting answer from google..
Any Help wiil be appreciated...



这篇关于从jquery到codebehind时,fileupload postedfile为null.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 12:42