[SOLVED] Open file uploaded with a button

Hi,
I 'am using upload_element with ajax script with an image instead of the name file in repeating group. Ok

I would like open the file with a button but I can't grab the link
The problem is :
var url2 =Fabrik.getBlock('form_3').formElements.get('table___element_table').getValue(); return NULL

So then this url is concat with url1 = http://xxxxxxx/index.html?input=
with window.open(url);

Or if it's possible grab the ajax link and put it in the url.
The directory is .htaccess protected

If someone could have an idea
Thanks
 
Hi cheese,
Thanks for replying
With a single ajax upload.
I do not understand how to rebuild the ajax link. I'd try to follow a thread with link + rowId
Thanks
 
OK, yeah, AJAX upload element, it looks like getValue() won't give you anything.

The current paths will be in url2.options.value, although for the single AJAX this will (I think) be JSON data, which is an array of objects, so ...

JSON.parse(url2.options.value)[0].file

... would be the path. Although you would want to do that in several steps, to make sure it decodes to an array, and the array isn't empty, etc.

-- hugh
 
I think I misspoke before. You need to grab the element object ...

Code:
var el =Fabrik.getBlock('form_3').formElements.get('table___element_table');

... then the paths are in el.options.value ... so to get the first one ...

Code:
var url2 = el.options.value[0];

... and if it's a JSON structure rather than the simple filename string ...

Code:
url2 = JSON.parse(url2).file;

-- hugh




 
Hi,
Thanks but now :
Nothnig fire :

Uncaught TypeError: Cannot read property 'options' of null => el is null

I need a simple filename string, but even with JSON I get the same result.

My script :

var url1 = 'https://www.xxxx.fr/images/dicom/viewers/mobile/index.html?input=';
var el = Fabrik.getBlock('form_3').formElements.get('a2s_dossier_expertise_50_repeat___verser_une_imagerie');
var url2 = el.options.value[0];
var url = url1+url2;
window.location.assign(url);

:confused:
 
Ok,
Sorry but the way have changed (o_O), this is now just a simple upload (not in ajax) but with a download script (both detail and form view).
I guess the way still remain the same no?

With element calc :
return basename('{a2s_dossier_expertise_50_repeat___verser_une_imagerie}'); then return the name file and put the value in url2 ?
But var url2 = ('element_calc').value; still return undefined! and with .htaccess there is no access !

or, and, I prefer that way :
How to rebuild this path in (url2):
https://www.mysite.fr/index.php?opt...82&formid=3&rowid=67&repeatcount=0&ajaxIndex=

And then concat url1+url

Sorry to boring you

repeating_group.png
 
Last edited:
Hi, a solution
"Thanks to my friend"

function a2s__getdicomAjaxURL (grpID)
{
var dicomFilename = "";
var elemHref = "";
var btnFilename = 'table_name_50_repeat___name_file_'+grpID;
var form = Fabrik.getBlock('form_3', false, function (block)
{
/*console.log("BLOCK", block);*/

/* get the filename (not used) */
var elemVal = block.elements.get(btnFilename).get('value');
/*console.log("DIRECT FILENAME", elemVal);*/
dicomFilename = elemVal+"dcm";

/* get the file's ajax-request path
nb : the path is stored in the "delete" button...
*/
var elemID = "table_name_50_repeat___verser_une_imagerie_"+grpID+"_delete_span";
elemHref = jQuery("#"+elemID+" a").attr("href");
/*console.log("DOM elemHref", elemHref);*/


/* FOR DEBUGS : loop on all elements of form_3 */
/* Object.each(block.elements, function (element, key)
{
console.log("EL / KEY", element, key);
if (key == btnFilename)
{
/ *console.log("EL / KEY", element, key);* /
console.log("-- IMG", element.get('value'));
}
});*/
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top