您可以使用jQuery的uploadify插件。
下面是示例代码我有asp.net
<script type="text/javascript">
// <![CDATA[
var id = "55";
var theString = "asdf";
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'scriptData': { 'id': id, 'foo': theString},
'cancelImg': 'uploadify/cancel.png',
'auto': true,
'multi': true,
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'queueSizeLimit': 90,
'sizeLimit': 4000000,
'buttonText': 'Choose Images',
'folder': '/uploads',
'onAllComplete': function(event, queueID, fileObj, response, data) {
}
});
});
然后你想一个处理程序(ashx的):
public class Upload : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file= context.Request.Files["Filedata"];
int id = (Int32.Parse(context.Request["id"]));
string foo = context.Request["foo"];
file.SaveAs("C:\\" + id.ToString() + foo + file.FileName);
context.Response.Write("1");
}
catch(Exception ex)
{
context.Response.Write("0");
}
}
}
什么问题,或者说它在哪里? – V4Vendetta 2012-04-10 05:31:52
检查客户端上传的任何图像的高度和宽度是不可能的。可能会有一些jQuery插件,试着用google搜索,但这个插件的体积很大。为了避免页面大小问题,您必须验证服务器端的图像高度和宽度。如果你建议你会得到代码。 – Murtaza 2012-04-10 05:53:53
你可以用简单的英语解释你需要什么吗? – Murtaza 2012-04-10 05:58:16