在用uploadify的时候遇到一个问题.
A页面代码:<table width="100%" border="0" cellspacing="0" cellpadding="0" class="TableBorder">
  <tr>
    <td style=" width:100px;">名称:</td>
    <td>
        <asp:TextBox ID="txtName" runat="server" Width="300"></asp:TextBox></td>
  </tr>
  <tr>
    <td valign="top">上传图片:</td>
    <td>
    <input type="file" name="file_upload_1" id="file_upload_1" />
    <div id="cp"></div>
        </td>
  </tr>
</table>
<asp:Button ID="bntA" runat="server" onclick="bntA_Click" Text="添加信息" />
<script type="text/javascript">
     $(function () {
         $("#file_upload_1").uploadify({
             'buttonText': 'select...',
             height: 20,
             swf: '/images/uploadify.swf',
             uploader: 'upload.aspx',
         });
     });
    </script>A.aspx是一个表单,点击按钮提交.upload.aspx是处理上传图片.会把上传的图片重命名为一个唯一标识的乱数名称.比如:201282111234.jpg现在问题是:在A.aspx中,因为我要取得上传的图片的重命名名称来提交到数据库,所以,我需要取得upload.aspx上传的图片的重命名名称(或者上传图片的全路径). 像上面的201282111234.jpg  这个是需要取得的.我如何做?谢谢

解决方案 »

  1.   

    在页面upload.aspx.cs里..先获取到文件名,再把文件名..改掉...入库..再返回给客户端...
      

  2.   


    $(document).ready(function () {
                var num;
                $("#uploadify").uploadify({
                    'uploader': '/js/ui/uploadify/images/uploadify.swf',
                    'script': '/ajax/ProductPic.ashx',
                    'scriptData': { userName: $("#hidUser").val(), levelID: $("#hidLevelID").val(), tag: Math.random() },
                    'method': 'get',
                    'cancelImg': '/js/ui/uploadify/images/cancel.png',
                    'queueSizeLimit': 5,
                    'maxSize': 1024 * 1024,
                    'fileExt': '*.jpg;*.gif;*.bmp;*.png',
                    'fileDesc': '*.jpg;*.gif;*.bmp;*.png',
                    'folder': '/upload/Picture',
                    'queueID': 'fileQueue',
                    'auto': false,
                    'multi': true,
                    'rollover': false,
                    onAllComplete: function (event, data) {
                        location.href = "WorksPictureUpload.aspx";
                    }
                });
            }); 
    HttpPostedFile file = context.Request.Files["Filedata"];
                    string fileName = file.FileName;
                    string fileType = fileName.Substring(fileName.LastIndexOf("."));
                    string saveFolder = DateTime.Now.ToString("yyyyMM");
                    fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString() + fileType;
                    string uploadPath =
                    HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";
      

  3.   

    我还是不明白。你这样写的话,在A.aspx里就可以得到upload.aspx的路径?
      

  4.   

    还有就是这里  'scriptData': { userName: $("#hidUser").val(), levelID: $("#hidLevelID").val(), tag: Math.random() },是做什么用的?谢谢!
      

  5.   

    传到upload.aspx的参数,可在upload.aspx获取。楼上正解
      

  6.   

    这样子:
                HttpPostedFile file = context.Request.Files["file"];
                if (file != null)
                {
                    if (id != 0)
                    {
                        try
                        {
                            Image i = Image.FromStream(file.InputStream);//判断是否是图片,不是会引发异常
                            byte[] imgDate = rarImage(i, 800, 1280, 80);//图片大小自动缩放
                            string ids = id.ToString("X8");
                            string uploadPath = HttpContext.Current.Server.MapPath(context.Request["folder"]) + "\\" + ids.Substring(0, 5) + "\\";
                            if (!Directory.Exists(uploadPath))
                            {
                                Directory.CreateDirectory(uploadPath);
                            }
                            string fn = uploadPath + ids.Substring(5, 3) + ".jpg";
                            File.WriteAllBytes(fn, imgDate);
                            
                            context.Response.Write(fn);// 传回文件名
                        }
                        catch
                        {
                            context.Response.Write("0");
                        }
                    }
                    else
                    {
                        context.Response.Write("0");
                    }
                    return;
                }下面data返回的就是传回的文件名        onUploadSuccess: function (file, data, response) {
                alert("file=" + file.name + "\n" + "data=" + data + "\n" + "response=" + response + "\n");
        
            },
      

  7.   

    onUploadSuccessTriggered for each file that successfully uploads.
     
    Argumentsfile
    The file object that was successfully uploadeddata
    The data that was returned by the server-side script (anything that was echoed by the file)response
    The response returned by the server—true on success or false if no response.  If false is returned, after the successTimeout option expires, a response of true is assumed.
      

  8.   

     'script': '/ajax/ProductPic.ashx',这里传你想跳转的页面
    'scriptData': { userName: $("#hidUser").val(), levelID: $("#hidLevelID").val(), tag: Math.random() },这个是你需要什么参数,就从本页面获取,再传到你跳转的页面中去。
    明白?
      

  9.   

    参考你这个.我是这样做的.在A.aspx里放一个html的hidden控件<input id="u1" type="hidden" name="u1" />在onUploadSuccess里这样写 onUploadSuccess: function (file, data, response) {
                     $("#u1").val($("#u1").val()+data+'|');
                 }在A.aspx.cs里这样获取值. string u1=Request.Form["u1"]);
    这样写测试了是可行的.但是总感觉有点别扭. jquery只懂一点. 像这样情况(在a页面获取b页面返回的值)标准的做法是怎样的?谢谢!