2012-05-11 3 views
0

그림을 내 시스템에 업로드하기위한 양식을 만들었지 만 그림 업로드에 실패했습니다.업로드 그림이 시스템에 오류가 발생했습니다.

내 웹 서비스가 내 시스템에 getCurrentTime()을 사용하여 연결되었는지 여부를 시도했지만 성공적으로 연결되었습니다.

제 친구는 서버 문제가 있다고 말해 왔지만 제 친구와 저는 우리 서버가 우리 시스템에 성공적으로 연결되었는지 확인하는 방법을 모릅니다.

누구든지이 문제에 대해 도움을 줄 수 있습니까?

감사합니다.

내 코드

protected void btnSave_Click(object sender, EventArgs e) 
    { 
     string fileName = string.Empty; 
     if (File2.PostedFile != null) 
     { 
      fileName = System.IO.Path.GetFileName(File2.PostedFile.FileName); 
     } 
     if (fileName != string.Empty) 
     { 
      if (!this.CheckFileFormat(fileName)) 
      { 
       WindowJS.WindowAlert("Image format is incorrect !"); 
       return; 
      } 
      string server = ImageURL; 
      string unique = Guid.NewGuid().ToString(); 
      string filePath = server.TrimEnd('\\').TrimEnd('/') + ImageURLRelative + unique + "." + fileName.Split('.')[1].ToString(); 
      // string LocalfilePath = Server.MapPath("..") + unique + "." + fileName.Split('.')[1].ToString(); 
      string uploadFileName = unique + "." + fileName.Split('.')[1].ToString(); 
      try 
      { 
       HttpPostedFile mFile = File2.PostedFile; 

       int fileSize = mFile.ContentLength; 
       int done = 0; 

       byte[] mFileByte = new Byte[fileSize]; 
       mFile.InputStream.Read(mFileByte, 0, fileSize); 

       string WebServiceUrl = string.Empty; 


       try 
       {      
        Rewards.high5.RedemptionUpload high5UploadService = new Rewards.high5.RedemptionUpload(); 

        if (Brand == "high5") 
        { 
         done = high5UploadService.UploadImage(uploadFileName, mFileByte); 

         if (done == 1) 
         { 

         } 
         else 
         { 
          WindowJS.WindowAlert("Error: Upload image fail."); 
          return; 
         } 
        } 
        //else if (Brand == "TLC") 
        //{ 
        // done = TLCUploadService.UploadImage(uploadFileName, mFileByte); 
        //} 


       } 
       catch (Exception ex) 
       { 
        WindowJS.WindowAlert("Error: Upload image fail."); 
        return; 
       } 
      } 
      catch (Exception ex) 
      { WindowJS.WindowAlert(ex.Message.ToString()); } 
      try 
      { 
       File2.PostedFile.SaveAs(filePath); 
       ImgUrl.ImageUrl = ImageURLRelative + unique + "." + fileName.Split('.')[1].ToString(); 
      } 
      catch (Exception ex) 
      { 
       WindowJS.WindowAlert(ex.Message.ToString()); 
      } 
      ViewState["IMG"] = ImageURLRelative + unique + "." + fileName.Split('.')[1].ToString(); 
     } 
     if (txtName.Text.Trim() == string.Empty) 
     { 
      WindowJS.WindowAlert("Please input the Name !"); 
      return; 
     } 
     try 
     { 
      Convert.ToDecimal(txtPoint.Text.Trim()); 
     } 
     catch 
     { 
      WindowJS.WindowAlert("Please input the Points correctly"); 
      return; 
     } 
     if (ViewState["Type"].ToString() == "E") 
     { 
      int rows = EditRedemption(); 
      if (rows == 0) 
      { 
       WindowJS.WindowAlert("Failed to modify"); 
      } 
      else 
      { 
       WindowJS.WindowAlert("Modified successfully"); 
       LoadInfo("V"); 

      } 


      return; 
     } 
     else if (ViewState["Type"].ToString() == "A") 
     { 
      AB5VIP.BLL.Redemption red = new AB5VIP.BLL.Redemption(); 
      if (red.Exists_RedName(txtName.Text.Trim())) 
      { 
       WindowJS.WindowAlert("This Redemption already existed !"); 
       return; 
      } 
      int rows = AddRedemption(); 
      WindowJS.WindowAlert(rows == 0 ? "Failed to save" : "save successfully"); 
     } 
     else if (ViewState["Type"].ToString() == "V") 
     { 
      AB5VIP.BLL.Redemption redlang = new AB5VIP.BLL.Redemption(); 

      int rows = redlang.UpdateRedemptionLang(Convert.ToInt32(ViewState["ID"].ToString()), ddlLang.SelectedItem.Value, txtName.Text, txtTitle.Text.ToString(), txtDesc.Text, Session["ABP_LoginName"].ToString(), System.DateTime.Now); 
      WindowJS.WindowAlert(rows == 0 ? "Failed to save" : "save successfully"); 
     } 
     lblCode.Text = string.Empty; 
    } 
+4

코드를 표시하십시오. –

+0

안녕 슈리 ~ 내가 내 코드를 게시했다 ~ –

+0

thx ravi 내 코드를 편집하는 데 도움이 ~ ~ 여기에 새로운 ~ 그걸로 흐려진다. –

답변

0

귀하의 응용 프로그램은 사진을 저장하는거야 폴더에 권한을 작성 필요가 없다. 실행중인 IIS 버전에 따라 ASPNET 사용자 (IIS 6) 또는 응용 프로그램 풀 (IIS 7)에 사용되는 계정에 대부분 사용 권한이 부여됩니다.

http://blogs.msdn.com/b/david.wang/archive/2005/08/20/why-can-i-upload-a-file-without-iis-write-permission.aspx

감사합니다.

+0

안녕하세요 오스카, 허가를 얻는 방법? 그 단계는? 대답은 –

+0

입니다. 말씀 드렸듯이 IIS 버전에 따라 실행됩니다. 네가 가진 게 뭐야? – Oscar

+0

실수가 아니라면 ~ 내 IIS 버전은 IIS 7입니다. –

관련 문제