Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
jquery ajax Send string data and file data PHP

I'm trying to send a file to the php file through ajax, the problem is when I try to send the data I need to sent it as String (mandatory) to locate the controller and the action (function) in this way:

jQuery.ajax({
            type: "POST",
            url: "/app/controllers/router.php",
            data: {
               controller: 'resource_management/language_control', action: "createLanguageControl", user: User, language: Language, course: Course, begin_date: BeginDate, end_date: EndDate, installments: Installments, monthly_amount: MonthlyAmount, max_reimbursement: MaxReimbursement, currency: Currency, TempDir : tempDir, DocName : docName
            },
            cache: false,
            success: function (r) {
            ...
});

So it passes by the router and read the controller and the action by string. How do I sent the file?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try something like this :

var file = "someFile.csv";
var data = new FormData();

var controllerData = JSON.stringify({
    controller: "resource_management/language_control",
    action: "createLanguageControl",
    .....
});
data.append("file", file);
data.append("string", controllerData);

$.ajax({
    url: '/app/controllers/router.php',
    method: "POST",
    data: data,
    contentType: false,
    processData: false,
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!