Page 1 of 2
attaching files
Posted: Wed May 01, 2019 3:49 pm
by dmier
Im having some troubles attaching files to a existing form, I have attached both images, one from the object form and phpadmin,
The problem is that when I save the file, the field goes blank, I already check phpadmin and its saved, what I want is display the image or at least a link to see the file
Re: attaching files
Posted: Thu May 02, 2019 9:29 am
by kev1n
Check out the JavaScript code of the "Stored Files" form.
Re: attaching files
Posted: Thu May 02, 2019 2:25 pm
by dmier
Code: Select all
function nuShowFile(){
var j = $('#sfi_json').val();
nuEmbedObject(j, 'view_image');
}
this one?
what about the input image? can it be done with that one? I can click on on it but It will not work
Or a Link to the attached file
Re: attaching files
Posted: Fri May 03, 2019 8:29 am
by kev1n
This is the relevant code of the "Stored Files" form:
Code: Select all
if(nuFormType() == 'edit'){
nuShowFile();
}
function nuBeforeSave(){
var f = $('#sfi_json_file').val();
if(f != ''){
$('#sfi_json')
.val(f)
.change();
}
return true;
}
function nuShowFile(){
var j = $('#sfi_json').val();
debugger;
if(j == ''){return;}
var ob = JSON.parse(j)
var ty = ob.type;
var ur = atob(ob.file);
var x = document.createElement("EMBED");
x.setAttribute("type", ty);
x.setAttribute("src", ur);
// x.setAttribute("width", "300px");
// x.setAttribute("height", "300px");
$('#view_image').html('');
document.getElementById('view_image').appendChild(x);
}
You need two objects:
1. Object to upload a file:
Type Input, Input Type File
ID: sfi_json_file
2. Object to display the image:
Type HTML
ID: view_image
with HTML:
<img
id="theview"
style="border:grey 1px solid;"
>
Re: attaching files
Posted: Fri May 03, 2019 5:07 pm
by dmier
I'm kind of lost, still not showing the image, I have attached pics, where is the JavaScript supposed to be located?
Re: attaching files
Posted: Fri May 03, 2019 5:34 pm
by dmier
there is an extra object in the file upload form, im really lost, need help.
Re: attaching files
Posted: Fri May 03, 2019 5:59 pm
by kev1n
Is the image displayed after saving?
Re: attaching files
Posted: Fri May 03, 2019 6:00 pm
by dmier
No, its not displaying the image
Re: attaching files
Posted: Fri May 03, 2019 6:15 pm
by dmier
I would be so happy, even if its just a display link.
Re: attaching files
Posted: Fri May 03, 2019 6:41 pm
by kev1n
Just a moment, please. I'll see if this works for me....