0

Hi Guys i create a component to upload files and its working so far, but along with the data I'll like to pass some parameters too, for example

HTML

<div class="col-md-4">
      <div class="container">
        <div class="large-12 medium-12 small-12 cell">
          <label>
            Files
      v-on:click="upload()">Submit</v-btn>
        </div>
      </div>
  </div>

Script

import
          axios.post('/api/upload', this.files)
      .then(resuta);
    }, error => {
      console.error(error);
    });
  }

here (axios.post('/api/upload', this.files)) i would like to include email: this.profile.email

Because I'm adding this parameter to the file name on my backend

Controller

[HttpPost, DisableRequestSizeLimit]
    public ActionResult UploadFile(string email)
    {

        var files = Request.Form.Files;
        foreach (var file in files)
        {

                }
            }

        }
        return Ok();
    }
3
  • What is this.files? Also, your fileChange method is missing its argument list Commented Feb 27, 2019 at 22:50
  • this.files is data() { return { records: [], application: [], profile: [], files: new FormData() Commented Feb 27, 2019 at 22:53
  • How can profile be an array and have a .email property? Where does profile.email come from and when / where is it assigned a value? Does that value ever change once it's assigned? Commented Feb 27, 2019 at 22:54

2 Answers 2

1

Given this.files is a FormData instance, you should be able to set any field you want. For example

upload () {
  this.files.set('email', this.profile.email)

  axios.post('/api/upload', this.files)...

I don't know .NET MVC very well any more but this would add email as a form param in the request.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use this way;

HttpContext.Request.Form.Where(p => p.Key == "email").FirstOrDefault().Value;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.