2

我正在使用带有asp的uploadify,我想在文件完成时将文件名更改为当前日期+时间。

有什么办法吗?

这是我的 JS 代码:

$('#fileUploadJquery').uploadify({
'uploader'      :   'Shared/ClientScripts/Uploadify/uploadify.swf',
'cancelImg'     :   'Shared/ClientScripts/Uploadify/cancel.png',
'rollover'      :   false,
'script'        :   'Shared/ClientScripts/Uploadify/upload.asp',
'folder'        :   'Uploads',
'fileDesc'      :   'Image Files',
'fileExt'       :   '*.jpg;*.gif;*.bmp;*.png',
'auto'          :   true,
'wmode'         :   'transparent',
onComplete      :   function (event, queueID, fileObj, response, data) {
    //$('#fileUpload').val(fileObj.name);
    alert(queueID)
}

请指教

4

4 回答 4

0

我正在使用uploadify直接从浏览器上传到S3。我很想知道有一种方法可以告诉 S3 将传入文件命名为用户本地计算机上的名称以外的名称。

于 2010-01-14T02:44:28.030 回答
0

您可能想查看 ScriptManager.RegisterClientScriptBlock()

将其放在代码隐藏中,并在服务器上重命名文件后调用该函数。这会调用客户端 JavaScript (javascriptFunctionName),它将新文件名传递给 Uploadify。这是一些C#:

    public void YourFunction(string fileName)
    {
      ScriptManager.RegisterClientScriptBlock(
        ctrlName,
        ctrlName.GetType(),
        "scriptkey",
        @"javascriptFunctionName('" + fileName + @"');",
        true);
    }    

希望这会有所帮助。这在您使用 ScriptManager 时与 AJAX 结合使用,并且会在代码隐藏完成处理后通知您的 Javascript 函数。

于 2010-01-14T03:11:16.913 回答
0

我正在使用uploadify,我已经改变了我的文件名,如下所示,检查我的OnComplete函数

'onComplete': function (a, b, c, d, e) {          
            var dt = new Date();                
                var file = c.name.split('.')[0] + "_" + dt.getUTCDate() + dt.getFullYear() + "." + c.name.split('.')[1];

            $("#hdntxtbxFile").val(file);
            UploadSuccess(file, "File"); //function call


            // }
        },

我希望它会帮助你

于 2012-12-26T11:05:47.207 回答
0

您需要在服务器脚本中进行文件操作。这是一个例子:

''// I'm using this component, but any component must work
dim theForm
set theForm = Server.CreateObject("ABCUpload4.XForm")

theForm.Overwrite = True
theForm.MaxUploadSize = 1000000


''// FileData is the name Uploadify gives the post value containing the file
dim theField
set theField = theForm("FileData")(1)


If theField.FileExists Then

   ''// Renamed the file adding a "random" string in front of the name
   dim FileName
   FileName =  replace(trim(cdbl(now())), ".", "_") + "_" + theField.FileName

   theForm.AbsolutePath = True
   theField.Save Server.MapPath("../uploadedfiles") & "/" + FileName

   ''// Some browser need this
   Response.write "<html><head><title>File uploaded</title></head><body>File uploaded</body></html>"


End If
于 2011-01-11T11:37:48.193 回答