|
uploadify.swf需要是支持中文 |
|
| $(function () { | |
| //獲取所有上傳按鈕id | |
| $("div[id^='fileInput_']").each(function () { | |
| var name = $(this).attr("id"); | |
| create(name); | |
| }); | |
| }); | |
| function create(name) { | |
| var select = "上傳圖片"; | |
| if (name.indexOf("_") > -1) { | |
| if (name.substring(name.lastIndexOf("_") + 1) == "1") { | |
| var select = "大圖"; | |
| } | |
| else if (name.substring(name.lastIndexOf("_") + 1) == "2") { | |
| select = "小圖"; | |
| } | |
| } | |
| $('#' + name).uploadify({ | |
| 'uploader': '/uploadify/uploadify.swf', | |
| 'script': 'Pro_Sub.aspx?upfile=1', | |
| 'cancelImg': '/uploadify/cancel.png', | |
| 'folder': '/ProductImg/', | |
| 'fileExt': '*.jpg;*.gif;*.png;*.bmp;*.JPEG;', | |
| 'fileDesc': '請選擇 *.jpg;*.gif;*.png,*.bmp;*.JPEG 格式的圖片', | |
| 'multi': true, | |
| 'auto': true, | |
| 'buttonText':select, | |
| 'onComplete': function (event, queueId, fileObj, response, data) { | |
| var re = response.split('|@|'); | |
| if (re[0] == "1") { | |
| var box = name.substring(10); | |
| var html = "<div class='ImgHtml' OnClick='change(this)'><input class='input2' style='display: none;' type='button' value='刪   除' onclick='delImg(this);showfi("+name.replace("_",".")+");' /><input type='checkbox' checked='checked' class='hide' value='" + re[1] + "' /><img class='Img' src='" + re[1] + "'></div>"; | |
| if (box == "1_0") { | |
| $("#ContentPlaceHolder1_rpAttribute_txtvalue_4").val(re[1]); | |
| html = "<div class='ImgHtml' OnClick='change(this)'><input class='input2' style='display: none;' type='button' value='刪   除' onclick='delImg(this);showfi(1)' /><input type='checkbox' class='hide' value='" + re[1] + "' /><img class='Img' src='" + re[1] + "'></div>"; | |
| $("#file0").hide(); | |
| } | |
| $(".box" + box).append(html); | |
| } else { | |
| ymPrompt.errorInfo({ message: "上傳失敗!", showMask: true }); | |
| } | |
| } | |
| }); | |
| } | |
| </script>
============================================================================= using System; using System.Web.SessionState; namespace Admin.TkAdmin.Product string upfile = Request["upfile"]; //對上傳的圖片進行保存到指定文件中 int rInt = ra.Next(1000); Session["IntIndexImg"] = rInt; newFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + rInt + Path.GetExtension(file.FileName).ToUpper(); }catch //用於創建目錄 } public bool IsReusable |
