如何在jvx框架中在上传过程中验证文件的类型和大小

huangapple go评论82阅读模式
英文:

How can i validate the type and size of a file during an upload in the jvx framework

问题

如何在使用ProjXUtil.uploadFile函数时验证文件的类型和大小?

ProjXUtil.uploadFile(this, new Var(mdbDokumente, "FILENAME"), new Var(mdbDokumente, "FILE_"));

无法设置更多关于文件类型和大小的参数。

英文:

How can i validate the type and size of a file when i am using the ProjXUtil.uploadFile function?

ProjXUtil.uploadFile(this, new Var(mdbDokumente, "FILENAME"), new Var(mdbDokumente, "FILE_"));

More parameters in over the function uploadFile for filetype and size are not possible to set

答案1

得分: 0

此实用程序仅将内容和文件名设置到mdbDokumente中。将触发valuesChanged事件。大小可以通过内容长度和文件名的文件类型进行评估。

英文:

This utility only sets the content and filename into the mdbDokumente. The valuesChanged event will be fired. The size can be evaluated by content length and the filetype with filename.

答案2

得分: 0

以下是您提供的代码的中文翻译部分:

我不使用实用程序而是使用以下代码片段

    UploadButton butUpload = new UploadButton();
    butUpload.eventAction().addListener(this, "doUpload");
    
    
    public void doUpload(UIActionEvent pEvent) throws Throwable
    {
    	IFileHandle fhandle = ((UploadButton)pEvent.getSource()).getFileHandle();
    		
    	if (book.getSelectedRow() >= 0)
    	{
    		String sFormat = FileUtil.getExtension(fhandle.getFileName().toLowerCase());
    
    		if ("png".equals(sFormat) || "jpg".equals(sFormat))
    		{
    			InputStream stream = fhandle.getInputStream();
    
    			
    			...
    
    
    			book.setValue("IMAGE", stream.toByteArray());
    		}
    	}
    }

请注意,我只提供了代码的翻译部分,没有包括问题或其他内容。

英文:

I don't use a utility, instead with following snippet:

UploadButton butUpload = new UploadButton();
butUpload.eventAction().addListener(this, "doUpload");


public void doUpload(UIActionEvent pEvent) throws Throwable
{
	IFileHandle fhandle = ((UploadButton)pEvent.getSource()).getFileHandle();
		
	if (book.getSelectedRow() >= 0)
	{
		String sFormat = FileUtil.getExtension(fhandle.getFileName().toLowerCase());

		if ("png".equals(sFormat) || "jpg".equals(sFormat))
		{
			InputStream stream = fhandle.getInputStream();

			
			...


			book.setValue("IMAGE", stream.toByteArray());
		}
	}
}

huangapple
  • 本文由 发表于 2023年5月10日 20:38:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76218530.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定