나는 asp.net에서 여러 파일을 업로드하기 위해 uplodify 3.1을 사용합니다. 그것은 여러 파일을 선택하고 업로드 할 수 있습니다. 하지만 내 probem 나는 각 항목에 대한 업로드 버튼을 클릭해야합니다.하나씩 업로드 파일을 올리기 하시겠습니까?
<head>
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/jquery.uploadify-3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).load(
function() {
$("#<%=FileUpload1.ClientID%>").uploadify({
'swf': 'Scripts/uploadify.swf',
'uploader': 'Upload.ashx',
'fileTypeDesc': 'Image Files',
'fileTypeExts': '*.jpg;*.jpeg;*.gif;*.png',
'multi': true,
'formData': { 'galerisi': '<%=Session["galeriId"]%>' },
'auto': false,
'buttonImage': 'Styles/images/btnYorumEkle.png',
'buttonText': 'Dosya seç'
});
}
);
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style="float: left;">
<asp:FileUpload ID="FileUpload1" runat="server" />
</div>
<div style="left: 136px; position: absolute; top: 18px;">
<a class="blueButton" href="javascript:$('#<%=FileUpload1.ClientID%>').uploadify('upload')">
Yükle</a>
</div>
<div style="left: 205px; position: absolute; top: 18px;">
<a class="blueButton" href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadClearQueue()">
Temizle</a>
</div>
</div>
</form>
</body>
과 ASHX 파일의 코드 :
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Web.SessionState;
public class Upload : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
galeriIslemleri galeriler = new galeriIslemleri();
Tools tollar = new Tools();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try
{
string galeriKlasoru = context.Request["galerisi"].ToString();
var db = Tools.DBBaglanti();
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "";
string tempPath = "";
tempPath = "images/galeriler/" + galeriKlasoru;
savepath = context.Server.MapPath(tempPath);
string filename = postedFile.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
postedFile.SaveAs(savepath + @"\" + filename);
context.Response.Write(tempPath + "/" + filename);
context.Response.StatusCode = 200;
galeriResimleri resimler = new galeriResimleri();
resimler.galeriId = Convert.ToInt32(galeriKlasoru);
resimler.resim = filename;
db.galeriResimleris.InsertOnSubmit(resimler);
db.SubmitChanges();
}
catch (Exception ex)
{
context.Response.Write("Error: " + ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
이 도와주세요 여기 내 코드 (aouto 속성은 false로 설정됩니다).
조회수 0 회 답변. 기록이어야합니다. – osmanraifgunes
다음 페이지에서보실 수 있습니다 : http://stackoverflow.com/questions/2501037/getting-uploadify-working-in-c-sharp – NotMe
그 주제를 전에 보았습니다. 하지만 내 문제는 다르다. 나는 uplodify를 사용하는 법을 안다. 보안 업로드를 위해 버전 3.2를 사용하고 싶습니다. auto 속성을 true로 설정하면 문제가 없습니다. 문제는 다음과 같습니다. "자동 속성을 잘못 설정하면 여러 사진을 업로드 할 때 각 사진의 업로드 버튼을 클릭해야합니다." – osmanraifgunes