marmelab / marmelab/ng-admin

Cannot Use field with file type

Open
#725 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
3.9k
Forks
703
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the category.creationView configuration shown in the issue, especially the nga.field('iconNormal', 'file') setup and its uploadInformation options. Reproduce selecting a file and opening Browse, then trace the file field behavior and upload response. Done means the selector opens with a single click and selecting a file produces the expected AngularJS upload response.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.