Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7438739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:36:05+00:00 2026-05-29T10:36:05+00:00

Server side, I use below function (used as espressjs middleware) function objCreation(req, res, next){

  • 0

Server side, I use below function (used as espressjs middleware)

function objCreation(req, res, next){
  req.form.complete(function(err, fields, files){
    if (err) {
       next(err);
    } else {
       // Set params in request
       obj = {};
       obj.label = fields.label;
       // Check if picture is provided
       if(files.image){
          // Move file to correct dir
          var fs = require("fs");
          var folder = '/var/images/';
          var src = files.image.path;
          var filename = files.image.name;
          var target = folder + filename;

          obj.filename = filename;
          req.obj = obj;

           fs.rename(src, target, function (status) {
             next();
          });
       } else {
          obj.filename = 'nofile';
          req.obj = obj;
          next();
       }
    }
  });
}

Basically, it receives the fields of a form submitted. This function uses “connect-form” node.js module.

Client side, I use an input text:

<input id="new_obj" type="text" placeholder="New"/>

and a callback triggered when return is hit on this input:

// Add callback for object creation
$('#new_obj').keypress(function(e){
  if (e.which == 13){
    createObj();
  }
});

The createObj function is the following one:

function createObj(){
 $.ajax({
   url: "/object/create/",
   type: "POST",
   data: { label : "label" },
   success: function(obj) {
     console.log(obj);
   },
   error: function(jqXHR,status,errorThrown) {
     alert(jqXHR.responseText + '-' + status + '-' + errorThrown);
   }
 });
}

I do not manage to have this last part sending a form in the correct format so it is processed with the server method. I do not want to change the server side as it is already used by some other clients (iOS client sending form with ASIFormDataRequest).

I’m currently having a look at ajaxForm jQuery plugin to see if this could help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:36:06+00:00Added an answer on May 29, 2026 at 10:36 am

    I managed to have this fixed by using the last version of expressjs that does not use connect-form anymore (deprecated) but uses formidable instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say,how to implement these three steps: 1.fetch a html source from server side 2.use
I know the use of server-side controls is a no-no in ASP.NET MVC, however
Creating a server-side socket will fail if I'm trying to use the same port
Is it really viable to use GCJ to publish server-side applications? Webapps? My boss
Has anybody tried to use JavaFX Script in server side applications? The language itself
i have a rhel 4 server and use php as a server side scripting
I need to use polling technique to notify clients about changes in server-side. So
I'm trying to use the DataAnnotationsModelBinder in order to use data annotations for server-side
When I have fields under a form tag, I use isset() function such as
when using spring rest server side generate json, it will looks like below {userInfo:{id:123,userFullName:full

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.