Page 1 of 2

attaching files

PostPosted: Wed May 01, 2019 11:19 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

PostPosted: Thu May 02, 2019 4:59 pm
by kev1n
Check out the JavaScript code of the "Stored Files" form.

Re: attaching files

PostPosted: Thu May 02, 2019 9:55 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

PostPosted: Fri May 03, 2019 3:59 pm
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

PostPosted: Sat May 04, 2019 12:37 am
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

PostPosted: Sat May 04, 2019 1:04 am
by dmier
there is an extra object in the file upload form, im really lost, need help.

Re: attaching files

PostPosted: Sat May 04, 2019 1:29 am
by kev1n
Is the image displayed after saving?

Re: attaching files

PostPosted: Sat May 04, 2019 1:30 am
by dmier
No, its not displaying the image

Re: attaching files

PostPosted: Sat May 04, 2019 1:45 am
by dmier
I would be so happy, even if its just a display link.

Re: attaching files

PostPosted: Sat May 04, 2019 2:11 am
by kev1n
Just a moment, please. I'll see if this works for me....