Squiz Matrix Multiple File Upload 2


(Ian Hirst) #21

This is great, got it working for an asset  builder page, but I've been trying to nest it within a custom form to allow multiple file uploads. It almost works, but I think because the asset builder is a <form>, it doesn't like being nested inside the <form> of the custom form. Any thoughts on whether the functionality of this plugin could be adapted for the custom form?


(Nic Hubbard) #22

This is great, got it working for an asset  builder page, but I've been trying to nest it within a custom form to allow multiple file uploads. It almost works, but I think because the asset builder is a <form>, it doesn't like being nested inside the <form> of the custom form. Any thoughts on whether the functionality of this plugin could be adapted for the custom form?

 

No planned development to support Custom Forms. Sorry about that!


(Robin Bilney) #23

Hey Nic,

 

Great tool thanks!  I did have it working at one point, but now it's throwing an error in the browser console and not uploading the file.

 

TypeError: input_name is undefined

 

The error occurs in the jquery.matrixupload2.js file at line 400.  Appears to be this function:

		_formData: function(asset) {
			var fd = new FormData();
			var type_code_file_input = $('input[name*="'+asset.typeCode+'_0"]:file');
			fd.append(type_code_file_input.attr('name'), asset.file);
			this.assetBuilder.formInputs.each(function() {
				var input_name = $(this).attr('name');
				var input_val;
				if (input_name.indexOf('CREATE_TYPE') != -1) {
					input_val = asset.typeCode;	
				} else {
					input_val = $(this).val();
				}
				fd.append(input_name, input_val);
			});
			return fd;
		},

Have you come across this before?

 

Thanks,

Robin


(Nic Hubbard) #24

Have you come across this before?

 

I have not seen this before. Has anything changed since you said it used to work? Could I look at the form?


(Robin Bilney) #25

Unfortunately it's on our intranet so I can't give you a link to take a look.  It was a simple Asset Builder that created an image. I've managed to fix the problem now by adding in an if statement to that function in the jquery.matrixupload2.js file:

 

        _formData: function(asset) {             var fd = new FormData();
            var type_code_file_input = $('input[name*="'+asset.typeCode+'_0"]:file');
            fd.append(type_code_file_input.attr('name'), asset.file);
            this.assetBuilder.formInputs.each(function() {
                var input_name = $(this).attr('name');
                var input_val;

                if (typeof input_name !== "undefined") {

                    if (input_name.indexOf('CREATE_TYPE') != -1) {
                        input_val = asset.typeCode;    
                    } else {
                        input_val = $(this).val();
                    }

                }

                fd.append(input_name, input_val);
            });
            return fd;
        },

 

 

There must have been an input field somewhere without a name attribute??


(Nic Hubbard) #26

Strange. Can you show me your code used to setup the plugin?


(Robin Bilney) #27

This is in my  $(document).ready function:

       // Uploading thumbnails to news stories
       if ( $("#thumbnail_upload").length > 0 ) { 
     $('form&#91;id*="asset_builder"]').matrixUpload({
       'layoutType': 'ZSSMatrixLayoutList', 
       complete: function(e,response) {
         console.log(e(response).find('#asset-id').text());
       },
       failed: function(e,response) {
         console.log(e(response).find('#asset-id').text());
       }
     });

   }

I've used the uploader in two different sections, one for news thumbnails the other for user profile pics.    #thumbnail_upload is a div wrapper around %create_form% on the Logged In bodycopy.


(Nic Hubbard) #28

Thanks. Never had this issue before. Would you be interested in submitting a pull request on Github for your fix?


(Robin Bilney) #29

Hey Nic,

 

That pull request has been done now.

 

Thanks,

Robin


(Nic Hubbard) #30

That pull request has been done now.

 

Thanks!


(Robin Bilney) #31

Hello again!

 

I've come across some interesting behaviour with Matrix / the file uploader.  I'm using the file uploader so people can upload a picture to their profile (it's saved under the user asset). If the image file has the same file name as an existing image, the uploader says 100% complete but doesn't upload the image.

 

Is there a setting in Matrix so that it automatically changes the filename? eg.  image.jpg -> image1.jpg

 

Thanks


(Nic Hubbard) #32

Matrix doesn't have this setting for Asset Builders unfortunately. It does for Custom Form file uploads, but that doesn't help here...


(Bart Banda) #33

We are currently working on a feature to be able to do this via a config setting on the asset builder. https://squizmap.squiz.net/matrix/9152

 

The way I've got around it in the past is to change the file name of every image that gets uploaded to something random, so use the current file name plus a random number or timestamp, update it via a trigger that runs on asset built.