ng-admin icon indicating copy to clipboard operation
ng-admin copied to clipboard

Cannot Use field with file type

Open pradithahidayat opened this issue 8 years ago • 4 comments

I tried to use field with file type to upload an image, but I didn't get any response from angular after I select a file from file selector. Also I have to double click the Browse button to open the file selector, and it's rarely works with double click, sometimes it won't open the file selector.

Here is how I implement the file type:

    category.creationView()
        .fields([
            nga.field('version', 'string')
                .label('Version')
                .attributes({ placeholder: 'e.g. 1.0' }),
            nga.field('name', 'string').label('Category Name'),
            nga.field('iconNormal', 'file')
                .uploadInformation({
                    'url': 'http://localhost:1337/category/upload',
                    'apifilename': 'file'
                })
                .label('Icon Normal'),
        ]);

I already test my upload function with postman and it's worked.

pradithahidayat avatar Oct 09 '15 02:10 pradithahidayat

Do you use last release of ng-admin, the 0.8 one ? If yes, sorry, you must use the master version until the new 0.9 version is out.

jeromemacias avatar Oct 09 '15 18:10 jeromemacias

@jeromemacias yes correct, I used the 0.8 version. Oke then, I'll wait for the new version.

Thanks for your response.

pradithahidayat avatar Oct 12 '15 02:10 pradithahidayat

@jeromemacias hi! I had the same problem and tried to use code from master. Now files uploading to server and returning new filename, but: when i submiting form, req.body.imgs contains old names with new names separated by comma. I tring to upload 6 files at 1 time and sometimes i getting 2 new names and 4 old. Sometimes i getting 5+1 or 0+6 new and old names of files. This is how field configured:

nga.field('imgs', 'file').uploadInformation({ 'url': 'admin/upload/', 'multiple': true, 'apifilename': 'filename'}) 

DmitryPogodaev avatar Oct 12 '15 20:10 DmitryPogodaev

Until we code a solution for the Image and Upload fields, here is a workaround: https://github.com/marmelab/ng-admin/issues/541#issuecomment-118265671

Kmaschta avatar Nov 18 '16 22:11 Kmaschta