无法在多个文件上传系统中上传具有相同名称的文件

时间:2018-04-18 06:51:16

标签: javascript jquery ajax

我有一个代码引用from this site,它允许我上传多个文件,并且还针对每次上传显示加载器。视图来自此类

enter image description here

整个过程的流程是用户点击"选择文件"并且可以在1个选择中选择多个文件,然后单击"上传按钮"文件上传。 在这里工作的另一个流程是,点击"选择文件"用户可以选择第一个文件,然后再点击"选择文件"他可以选择第二个文件等等。然后最后他可以点击上传按钮并将所有文件一起上传

如果我尝试上传2个同名文件,则会出现问题。

保存在服务器文件夹中时,我更改了文件名。但是在上传之前,如果有2个同名文件,那么它就不会上传,或者重新上传整个文件集

代码有多个文件,并且在这里给出了部分代码,但是没有给出任何清晰度,所以我只给出了我添加的一部分代码来改变后端文件的名称但是如果你能从here下载代码并帮助我解决这个问题,我将非常感激

添加了代码以更改在后端上传的文件的名称(下载文件夹中的upload.php文件)

 <thead>
                    <tr>

                        <th id="profilepic" data-tag="Image" style="text-align:center;min-width:50px">Image</th>
                        <th id="empName" data-tag="Employee" style="text-align:center;min-width:50px">Employee</th>
                        <th id="0000">00:00</th>
                        <th id="0030">00:30</th>
                        <th id="0100">01:00</th>
                        <th id="0130">01:30</th>
                        <th id="0200">02:00</th>
                        <th id="0230">02:30</th>
                        <th id="0300">03:00</th>
                        <th id="0330">03:30</th>
                        <th id="0400">04:00</th>
                        <th id="0430">04:30</th>
                        <th id="0500">05:00</th>
                        <th id="0530">05:30</th>
                        <th id="0600">06:00</th>
                        <th id="0630">06:30</th>
                        <th id="0700">07:00</th>
                        <th id="0730">07:30</th>
                        <th id="0800">08:00</th>
                        <th id="0830">08:30</th>
                        <th id="0900">09:00</th>
                        <th id="0930">09:30</th>
                        <th id="1000">10:00</th>
                        <th id="1030">10:30</th>
                        <th id="1100">11:00</th>
                        <th id="1130">11:30</th>
                        <th id="1200">12:00</th>
                        <th id="1230">12:30</th>
                        <th id="1300">13:00</th>
                        <th id="1330">13:30</th>
                        <th id="1400">14:00</th>
                        <th id="1430">14:30</th>
                        <th id="1500">15:00</th>
                        <th id="1530">15:30</th>
                        <th id="1600">16:00</th>
                        <th id="1630">16:30</th>
                        <th id="1700">17:00</th>
                        <th id="1730">17:30</th>
                        <th id="1800">18:00</th>
                        <th id="1830">18:30</th>
                        <th id="1900">19:00</th>
                        <th id="1930">19:30</th>
                        <th id="2000">20:00</th>
                        <th id="2030">20:30</th>
                        <th id="2100">21:00</th>
                        <th id="2130">21:30</th>
                        <th id="2200">22:00</th>
                        <th id="2230">22:30</th>
                        <th id="2300">23:00</th>
                        <th id="2330">23:30</th>
                    </tr>
                </thead>
                <tbody id="body1"></tbody>
//Here Iam appending the Row using Jquery
            </table>

任何人都可以告诉我如何在上传到后端之前更改文件名称

负责上传is here

的脚本

2 个答案:

答案 0 :(得分:1)

 <input class="uploadGAConnection" #uploadFile  type="file" (change)="uploadGAConnectionDetails($event)" placeholder="Upload file" accept=".csv,.json" (click)="uploadFile.value=null">

只需提供参考,并将其每次点击的值设置为null。

答案 1 :(得分:0)

将新文件名设为如下

$ shortname = time()。' - '。$ _ FILES ['newsImage'] ['name'];

$ shortname = str_replace(“”,“_”,basename(trim($ shortname)));

$ vpb_file_name = $短名称;

相关问题