Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共9 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:Uploader 中止上传

1楼
科明123 发表于:2024/8/14 16:23:00
在change事件里监听图片日期,若不符合条件,则中止该文件上传或删除该文件,这段代码应怎样写?

const up1 = document.getElementById('up1');

up1.addEventListener('change', getdatetimeoriginal,false);

function getdatetimeoriginal(e){
var file = e.target.files[0];
var OriginalDate;
EXIF.getData(file, function(){
OriginalDate = EXIF.getTag(this, 'DateTimeOriginal');
});
if (!CheckDate(OriginalDate)){
//中止上传
}
}

2楼
有点蓝 发表于:2024/8/14 16:28:00
上传的代码在什么地方?
3楼
科明123 发表于:2024/8/14 16:39:00
With wb.AddInputGroup("form1","ipg5","")
With .AddUploader("up1","附件(上传拍照):")
.AllowDelete = True '允许删除
.Incremental = True '允许重复选择文件或连续拍照
For Each filename as string In Filenames
If Filesys.DirectoryExists(ProjectPath & "web\" & UserName) = False Then
Filesys.CreateDirectory(ProjectPath & "web\" & UserName)
End If
If ftp.DownLoad(filename,ProjectPath & "web\" & UserName & "\" & FileSys.GetName(filename)) = True Then
.AddImage("./" & UserName & "/" & FileSys.GetName(filename))
End If
Next
End With
.AddHidenValue("Opdate0","2018-01-01")
.AddHidenValue("Dpdate0","2018-01-01")

End With

wb.AppendHTML("<script src='./lib/exif.js'></script>") '引入脚本文件
wb.AppendHTML("<script src='./lib/getexif1.js'></script>") '引入脚本文件

4楼
科明123 发表于:2024/8/14 16:45:00
测试了一下,这个change事件是发生在调文件到UPLOADER图像分组框中发生的,此时还没有提交。这个过程能否中止文件调入UPLOADER分组框?
5楼
有点蓝 发表于:2024/8/14 17:21:00
3楼是接收,不是上传。前端上传的代码在什么地方?
6楼
科明123 发表于:2024/8/14 17:28:00
With wb.AddInputGroup("form1","ipg5","")
With .AddUploader("up1","附件(上传拍照):")
.AllowDelete = True '允许删除
.Incremental = True '允许重复选择文件或连续拍照
End With
.AddHidenValue("Opdate0","2018-01-01")
.AddHidenValue("Dpdate0","2018-01-01")

End With

wb.AppendHTML("<script src='./lib/exif.js'></script>") '引入脚本文件
wb.AppendHTML("<script src='./lib/getexif.js'></script>") '引入脚本文件
' wb.AppendHTML("<script>up1.addEventListener('change', function(e){EXIF.getData(e.target.files[0], function() {document.getElementById('pdate').value=EXIF.getTag(this, 'DateTimeOriginal')})},false );</script>")
' wb.AppendHTML("<script>up1.addEventListener('change', function(e){EXIF.getData(e.target.files[0], function() {document.getElementById('pdate1').value=EXIF.getTag(this, 'DateTimeDigitized')})},false );</script>")

        With wb.AddButtonGroup("form1","btg1")
            .Add("btn1","保存","button").Attribute ="onclick = submitForm()"
            .Add("btn2","返回","button").Attribute =""
        End With  



function submitForm(){
    show("tst1",2000);
    var result = submitAjaxForm('form1','',false);
    if (result =='OK') {show('dlg1')}
    else if (result == 'Photo') {show('dlg3')}
else {showDialog('dlg2','错误',result)}
}

7楼
有点蓝 发表于:2024/8/14 17:33:00
使用js变量判断

const up1 = document.getElementById('up1');

up1.addEventListener('change', getdatetimeoriginal,false);
var isupload = true;
function getdatetimeoriginal(e){
var file = e.target.files[0];
var OriginalDate;
EXIF.getData(file, function(){
OriginalDate = EXIF.getTag(this, 'DateTimeOriginal');
});
if (!CheckDate(OriginalDate)){
//中止上传
isupload = false; }
else{isupload = true;}
}


function submitForm(){
if (isupload ){
    show("tst1",2000);
    var result = submitAjaxForm('form1','',false);
    if (result =='OK') {show('dlg1')}
    else if (result == 'Photo') {show('dlg3')}
 else {showDialog('dlg2','错误',result)}
}
}
8楼
科明123 发表于:2024/8/14 18:25:00
这样处理会取消所有文件的上传,能不能排除不符合要求的文件,再提交其余符合要求的文件?
9楼
有点蓝 发表于:2024/8/15 8:36:00
试试,下面,如果不行就没有办法,只能使用第三方的上传组件,或者使用原生的file input标签自己做

if (!CheckDate(OriginalDate)){
//中止上传
e.target.files.splice(0, 1);
  }
共9 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02905 s, 2 queries.