-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello EveryOne, I want to upload and download pdf file, it uploads well but at the time of download using toolbar button link click, it is only loading page but cant download.
<zk> <window id="mainInputWindow" apply="com.bi.ekyc.composer.InputForm_Mod_Composer" width="100%">
<label id="user" sclass="user_label" />
<borderlayout height="700px">
<west sclass="menu_back">
<panel class="scroll-down">
<panelchildren>
<panel title="eKYC and eCRP">
<panelchildren>
<grid id="fileAttachmentGrid" >
<rows>
<!-- <row>
<cell id="attachmentCell" colspan="8">
<toolbarbutton id="attachedFileTbBtn" />
<toolbarbutton id="removeFileTbBtn" />
</cell>
</row> -->
<row id="fileAttachmentRow" visible="false" >
<cell id="attachmentCell" colspan="3">
<toolbarbutton id="attachedFileTbBtn" />
<toolbarbutton id="removeFileTbBtn" />
</cell>
<cell colspan="1">
<label id="upload_date" />
</cell>
<cell id="fileLabelCell" colspan="1">
<label value="File:" />
</cell>
<cell id="buttonCell" colspan="7">
<toolbarbutton upload="true" id="fileAttachmentTbBtn" />
</cell>
</row>
</rows>
</grid>
public void onUpload$fileAttachmentTbBtn(Event event) {
isFileUploadNow = true;
// String uploadedFileName ;
try {
UploadEvent uploadEvent = (UploadEvent) ((ForwardEvent) event).getOrigin();
Media m = uploadEvent.getMedia();
uploadedFileName = m.getName();
System.out.println("Uploaded File Name: " + uploadedFileName);
// saving File Temp Location
fileUpdDelUtil.saveTempFile(m, bulk_ul.getUSER_ID());
int isFileAllowed = fileUpdDelUtil.validateUploadedFileType(m,
fileUpdDelUtil.WIN_TEMP_DIR_PATH + "/" + bulk_ul.getBRANCH_CODE() + "/" + m.getName());
if (isFileAllowed == 1) {
// setting the form for file is Attached
filePresent();
// limiting file name to 45 letters and if its less than 50 leaving it as it is
if (uploadedFileName.length() > 50) {
attachedFileTbBtn.setLabel(uploadedFileName.substring(0, 45));
} else {
attachedFileTbBtn.setLabel(uploadedFileName);
}
// setting the attributes to insert in database and other functionalities
attachedFileTbBtn.setAttribute("filePath", fileUpdDelUtil.WIN_AUD_PATH_URL);
attachedFileTbBtn.setAttribute("filePathDir", fileUpdDelUtil.WIN_AUD_DIR_PATH);
// setting controls properties for Toolbar button
attachedFileTbBtn.setTooltiptext(uploadedFileName);
attachedFileTbBtn.setStyle(ResourceUtility.fontColorBLUE);
attachedFileTbBtn
.setHref(fileUpdDelUtil.WIN_TEMP_PATH_URL + "/" + bulk_ul.getUSER_ID() + "/" + m.getName());
attachedFileTbBtn.setTarget("_blank");
} else {
Messagebox.show(
"upload Failed Not Allowed \nSelect Only " + fileUpdDelUtil.getKnownFileExt() + "File Type");
}
} catch (Exception e) {
e.printStackTrace();
}
}
You don't attach your screenshot successfully. Could you attach it again? That would help others understand your problem better. According to the current information, it's hard for me to tell the root cause.
Is attachedFileTbBtn
the button to download a file?
What do you mean "... loading page but cant download...."? Do you mean: after clicking the button, your browser shows a PDF file, but cannot download it, is it?
Have you ever checked the generated link, fileUpdDelUtil.WIN_TEMP_PATH_URL + "/" + bulk_ul.getUSER_ID() + "/" + m.getName()
is correct or not?
Suggest you to open the browser developer tool > network and console tab (press F12) to check if there is any error or unexpected result:
Asked: 2022-10-04 14:32:27 +0800
Seen: 6 times
Last updated: Oct 06 '22
updated your karma so that you can include links and images.
jeanher ( 2022-10-07 09:27:20 +0800 )edit