英文:
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());
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论