Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

File Object Not Saving File

Questions related to using nuBuilder Forte.
Locked
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

File Object Not Saving File

Unread post by tonyd »

I have a File Object (in a collection of other objects) in a subform. When I click the "browse" button on the File Object everything seems to work fine . . . file select window pops up, user selects file, filename shows up in the File Object on the subform. However, when I click save on the main form, the filename disappears from the File Object and is replaced with "No file selected." Something is getting saved in the underlying table, but it seems to only save the other objects on the subform, not the File Object.

I hope that is descriptive enough to give everyone a mental image of my problem.
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: File Object Not Saving File

Unread post by admin »

tonyd,

Can you give us a screenshot?

Steven
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: File Object Not Saving File

Unread post by tonyd »

Before adding a file
beforeselection.jpg
After selecting a file
beforesave.jpg
After clicking "save"
aftersave.jpg
You do not have the required permissions to view the files attached to this post.
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: File Object Not Saving File

Unread post by admin »

tonyd,

That is the way it is supposed to work.

An Input:File Object is for selecting a file, not for displaying anything.

Just like in the Files Form.
input_file_object.PNG
Steven
You do not have the required permissions to view the files attached to this post.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: File Object Not Saving File

Unread post by tonyd »

I think I understand. Then what I need to know is whether I can store the file somewhere (database, filesystem, cloud) that would allow for later retrieval? The filesystem would be the best due to the expected large numbers of saved files, but that would go against the whole nuBuilder idea of keeping everything in one easy-to-manage location, the database. I know a MySQL database can hold quite large file sizes, but I just don't trust a database for file storage.

BTW, I am not really concerned (yet) with displaying the files.
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: File Object Not Saving File

Unread post by admin »

tonyd,

Even though an Input:File Object doesn't display the file name after it saves, it will still save the file to the database once you click the Save Button.


Steven
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: File Object Not Saving File

Unread post by tonyd »

OK, is there a way within nuBuilder to download or view the file (assuming it is a PDF or graphics file) once it is in the database?
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: File Object Not Saving File

Unread post by admin »

TonyD,

The File Button will lead you to a Form that has code that is used to display files.
displaying_files.PNG
This is that code...

Code: Select all


nuSetNoSearchColumns([2,3]);

$('[data-nu-column="0"]').each(function( index ) {

    var code    = '#nucell_' + index + '_';
    window.nuImages[$(code + '0').text()] = $(code + '2').text();
    
});



if(nuFormType() == 'browse'){
    nuShowBrowseImages()
}else{
    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();
    	
	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);
        
}


function nuShowBrowseImages(){

    $('[data-nu-column="0"]').each(function( index ) {
		
		var p	    = $(this).attr('id');
		var r	    = String(p).split('_')[1];
		var i       = "nucell_" + r + "_2";
		var e       = "nucell_" + r + "_3";
		var h       = $('#' + i).html();

		if(h != '' && h !== undefined){

        	var ob	= JSON.parse(h)
        	var ty	= ob.type;
        	var ur	= atob(ob.file);
            var x   = document.createElement("EMBED");
            
            x.setAttribute("type", "embed" + i);
            x.setAttribute("type", ty);
            x.setAttribute("src", ur);
            x.setAttribute("width", "140px");
            x.setAttribute("height", "140px");

            $('#' + e).html('');
            document.getElementById(e).appendChild(x);
        
		}
		
	});

}



Steven
You do not have the required permissions to view the files attached to this post.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: File Object Not Saving File

Unread post by tonyd »

Thanks Steven. I will give this a try.
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: File Object Not Saving File

Unread post by admin »

.
Locked