在ajax async fileupload中保存文件名的问题 [英] probleum in saving file name in ajax async fileupload

查看:132
本文介绍了在ajax async fileupload中保存文件名的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajax异步文件上传到上传文件上传之前我添加了当前日期时间,文件名和文件上传工作正常但是当我要将它保存在数据库中时,它保存了0ld名称的文件有什么办法在文件上传中显示新文件名?

我当前的代码是

i am using ajax async file upload to to upload file before upload it i add current date time with file name and file upload working properly but when i am going to save it in database it saves file with 0ld name is there any way to display new file name in file upload ??
my current code is

protected void fileUploadComplete6(object sender, AsyncFileUploadEventArgs e)
{
    try
    {
        Thread.Sleep(2000);
        string currentDateTime = String.Format("{0:yyyy-MM-dd_HH.mm.ss.ffftt}", DateTime.Now);
        string filename = currentDateTime + "_" + System.IO.Path.GetFileName(txtOtherDoc2.FileName).Replace(" ", "_");
        txtOtherDoc2.SaveAs(Server.MapPath("~/Document/") + filename);
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

推荐答案

这种情况发生,因为当你做save​​as时它不会改变txtOtherDoc2 .FileName而不是

它创建了一个新文件,其中包含你在saveas中提供的名称作为参数并复制其中的内容。



那你是什么需要做的是分配你在saveas方法中作为参数提供的tenderDetail.OtherDoc2filename。



如果您需要任何澄清,请与我们联系。
This happening because when you do saveas it does not change txtOtherDoc2.FileName instead
it creates new file with name you have provided in saveas as parameter and copy the content in it.

So what you need to do is assign tenderDetail.OtherDoc2 "filename" you have provided as parameter in saveas method.

Please let me know if you need any clarification.


这篇关于在ajax async fileupload中保存文件名的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆