How to upload multiple files into different documents in XPages? - file-upload

I have a need to upload up to 5 files at the same time using 5 different file upload controls and all files need to be stored into seperate notes documents. there should be only one save button
So if I upload 5 files and save there should be 5 Notes documents containg 1 file each
how can I do this?

I've not cleaned this up enough from MWLug - my my solution is fileVault which you can grab here. https://bitbucket.org/leedy/filevault
There are slides inside the repository but I don't have true documentation yet. The next step will be a NotesIn9 Video that's coming very soon.
What this is, is a combination of PLupload and Java so allow the uploading of multiple files that get saved 1 per document in a series of Vault databases. There are 3 databases for JPG's.. (Original, Large, and Small) and 1 .nsf for other files.
I don't use the built in file upload or download control at all. So if you really want that you can ignore this.
I have some custom controls in there for displaying pictures and files as well as a lightbox custom control - Galleria.
We use this in production currently but this version of it could use some more cleaning up and documentation. but you're welcome to try it.
The repository has the raw source which is best to use but it also has compiled templates if that's easier.
Good Luck

Create an xpage with 5 panels, bind each to different document data source with ignoreRequestPatams=false.
Have a file upload and download control inside each panel.
Select full update for the file upload on change event.
Create save button on top of all 5 panels to save all 5 data sources.

I found one solution that seem to work.
I put a document datasource and a file upload control in a repeat and then use a link to save all data sources. I set the repeat to 5 and this will create 5 documents.
In postSaveDocument on the data source I delete the onces that did not contain an attachment
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel>
<xp:repeat id="repeat1" rows="30" value="#{javascript:5}">
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="d" formName="Main">
<xp:this.postSaveDocument><![CDATA[#{javascript:if(#AttachmentLengths()==0){
d.getDocument().remove(true)
}}]]></xp:this.postSaveDocument>
</xp:dominoDocument>
</xp:this.data>
<xp:fileUpload id="fileUpload1" value="#{d.Body}"></xp:fileUpload>
</xp:panel>
</xp:repeat>
</xp:panel>
<xp:link escape="true" text="Save" id="link1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:save(true)}]]></xp:this.action>
</xp:eventHandler>
</xp:link>

Related

Upload webscrapped images from folder to database Django

I'm webscrapping data about ski resorts from a site, also getting some pictures. I am saving those pictures in a folder and after that i'm getting them in SQLite database through an imageField.
The bad part is that they don't work
directory = r'C:\Users\tiberiu.ghimbas\Documents\Resorts img5'
image_list = [cv2.imread(file) for file in
glob.glob(r'C:/Users/tiberiu.ghimbas/Documents/Resorts img5/*.png')]
This list is then looped and insertet item by item.
I'm doing all the correct settings for handling images and media files.
I know that by going the classic way of uploading images through a form will get you in the database the path to the image from de media/"upload_to = 'filename'" folder but going by my way i'm getting only them image name.
How can i solve that ?

Why won't my docbook links work when linking to something earlier in the document?

I'm going from docbook to fo to pdf and I need to have text that goes to different parts of the document when clicked. I'm using the following format
<link linkend="M1350424Trace">
<emphasis role="bold">Link To Trace</emphasis>
</link>
Where M1350424Trace is the id of a paragraph. It works how I want it to work when I'm linking to something that comes later in the document but not when it's trying to link to something that comes earlier. Why is that?
Here's the .fo
<fo:basic-link internal-destination="M1350424Trace">
<fo:inline>
<fo:inline font-weight="bold">Link To Trace</fo:inline>
</fo:inline>
</fo:basic-link>
I've reproduced your case with the following input data:
Sample DocBook file with link and xref as a linkage mechanism
link and xref both and the target id are on different pages after rendering.
DocBook 5.1 as a source.
DocBook XSL 1.79.1 - as a stylesheets.
FOP 2.3 as a renderer.
The produced PDF file was tested with xpdf 3.04, Acrobat Reader 7.08 on Linux Debian 9.5
Works as should be: pressing the link moves to the page with a required element (para) with a required id number.
So you need to provide the exact file and exact configuration that raised this strange behavior. You can fill it with a dump data in case your document is under NDA or contains sensitive information, BUT it should be the same in matter of structure and elements within as an original one.
I'll try to reproduce your case.

pe:documentviewer nameddest attribute doesn't work

I'am trying to show a pdf in a p:dialog , but i want to open pdf in a spécific destination, there is my code:
<p:commandLink value="test" oncomplete="PF('dlg').show()"/>
<p:dialog header="Dialog" widgetVar="dlg"
resizable="false"
fitViewport="true">
<pe:documentViewer height="500" width="800"
nameddest="nature"
name="helpImmo.pdf"/>
</p:dialog>
So the pdf is opened but in the first page
NB:when i use the page attribute it works
Attribute nameddest of pe:documentViewer can be used to open PDF in specific named destination which is technically different then bookmark.
To test if your code and project libraries work correctly, download this pdf example, include it into your project and in pe:documentViewer and set, for example, nameddest="Chapter3".
I've tested it with PF 6.1 and PF-extensions 6.1. It works OK on my side and opens requested named destination.
So make sure that
your PDF actually has named destination 'nature' created,
your version of PF-extensions does not have some known issue related to opening named destinations.
Also you can programmatically add named destinations to your PDF with iText java library as described in this example.

Moving uploaded files in Socialengine

I tried moving uploaded file through browse action in socialengine from /public/user/ to /Files/SE/ by using
1.
$fileobj = new Zend_Cloud_StorageService_Adapter_FileSystem();
$fileobj->moveItem($sourcePath, $destinationpath);
move_uploaded_file($sourcePath, $destinationpath);
Both of these couldn't move the file. I have checked the paths too they are perfect and works with other frameworks
You should use API of Storage module which will allow you to create temporary files (when you need to resize images or convert videos) and then place them into public storage. This files will be tracked in engine4_storage_files table.
I got it worked by using createSystemFile() function under storage > Model > DbTable > Files.php
I created a function similar to this and gave parent_type as the folder which I wanted to move in the files.

Why can't I attach my uploaded file to an email?

I have a form with a file input:
<input type="file" id="uploadFile" name="uploadFile" />
I submit the form using the ajaxForm method of the JQuery form plugin.
Then, in the code to handle the post, I read and process the file. I use cfspreadsheet to read the file directly from the file input field:
<cfspreadsheet
action="read"
src="#form.uploadFile#"
sheet="1"
query="spreadsheetData"
headerRow="1"
excludeHeaderRow="true"
>
This all works correctly.
I decided that I want to email the spreadsheet to the administrator as well. I thought I could accomplish this simply with a cfmail tag that includes the following cfmailparam tag:
<cfmail to="myEmailAddress#email.com"
from="fromEmail#email.com"
subject="Upload File" type="HTML">
<cfmailparam file="#form.uploadFile#" />
File processed successfully
</cfmail>
However, this is not working correctly - the email is not sent. What am I doing wrong?
Leigh's solution works well and you have probably already implemented in your code. I thought I'd put my 0.02 cents in about why this is a problem to begin with.
When you upload a file the file is placed in a temp folder location. If you do nothing with the file to put it in a final destination the file is deleted - probably at the end of your request.
Meanwhile the cfmailparam does not actually attach the file at runtime. It leaves it to the spooler process to do that. If you take a look in your ColdFusion installs "mail/spool" directory you will see a file with .cfmail extension. If you can't "catch" one before delivery check your undeliverable folder - there's bound to be a few hanging around in there.
The .cfmail file serves as an instruction to the spooler service which sends the mail. It has a subject, from, to, server address, body etc.
If you attach a file you will see something at the bottom of this file that looks like this:
file: D:\jrun\temp\blah.tmp
file-type: application/octet-stream; name="I am the file you uploaded.tmp"
file-disposition: attachment
remove: false
At runtime CF grabs this file and does what Leigh is suggesting - places it as binary with a mailpart (base64 encoded) into the main body of the message. So what is happening is that by the time the spooler service gets around to attempting to open and attach this file the file is long gone because the request has ended. I also think that the file exists with a ".tmp" extension in this temporary directory - which is obviously not what you want to attach (but that could be a previous version of CF).
To fix it, first use cffile with the "upload" action to put the file in a real (instead of temporary) folder on the disk. Then use cfmailparam to attach the file. NOTE: The "remove" attribute set to yes will cause CF to delete the file once it has successfully sent the mail - which is the effect I believe you are looking for.