2013-10-02 6 views
0

uplodifiy를 사용하여 사진을 업로드하고 있습니다. 여기 내 코드는 아래에 있습니다. 그러나 Upload.ashx 핸들러 안에 이 있습니다. 제출 된 값 (Id 및 foo 값)을 얻습니다. 즉, null 값을 반환합니다. 어떻게이 문제를 해결할 수 있습니까? 감사합니다. 나는이ashx 파일 내에서 클라이언트 측 값을 얻습니다.

$(document).ready(function() { 

     var id = "55"; 
     var theString = "asdf"; 

     $("#<%=FileUpload1.ClientID%>").uploadify({ 
      'uploader': 'Upload.ashx', 
      'swf': 'uploadify/uploadify.swf', 
      'script': 'Upload.ashx', 
      'cancelImg': 'images/cancel.png', 
      'folder': 'upload', 
      'multi': true, 
      'buttonText': 'RESIM SEC', 
      'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg', 
      'auto': false, 
      'scriptData': { 'id': id, 'foo': theString} 
      ,onAllComplete: function (event, data) { 

      } 

     }); 
    }); 

이처럼 내 ASHX 파일과 같은 코드를 가지고;

public void ProcessRequest(HttpContext context) 
    { 
     context.Response.ContentType = "text/plain"; 
     context.Response.Expires = -1; 
     try 
     { 

    //I tryed both way to get values both both return null values. 
      string pwd1 = context.Request["Id"]; 
      string pwd2 = context.Request.Form["Foo"]; 



      HttpPostedFile postedFile = context.Request.Files["Filedata"]; 
      string id = context.Request["id"]; 
      string savepath = ""; 
      string tempPath = ""; 

      tempPath = context.Request["folder"]; 

      //If you prefer to use web.config for folder path, uncomment below line: 
      //tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; 


      savepath = context.Server.MapPath(tempPath); 
      string filename = postedFile.FileName; 
      if (!Directory.Exists(savepath)) 
       Directory.CreateDirectory(savepath); 
      string ext = System.IO.Path.GetExtension(filename); 
      string resimGuid = Guid.NewGuid().ToString(); 
.......... 
.......... 

답변

1

사용 와 formData 포스트 방법 방법 옵션이 설정되어있는 경우, '수'또는 헤더를 통해 설정되어있는 경우

추가 데이터가 쿼리 문자열 중 하나로 스크립트에 전달 될 수있다 '게시'. 이것은 formData 옵션을 사용하여 모두 완료됩니다. 메소드 옵션 ('post'또는 'get')으로 설정 한 내용에 따라 서버 측에서 formData 옵션으로 보낸 정보를 검색 할 수 있습니다.

자세한 내용을 참조하십시오 Passing Extra Data

+0

perfecct, 정말 고마워요. – sakir