0

I have a HTML form that takes few details from the user along with a picture.

<div id="form_page">
  
            <div id="form_body">
                <div id="head">
                    <h1 id="heading">Candidate registration</h1>
                </div>
                <br />
                <div id="input_name" class="input">
                    <input id="name" type="text" 
                        Placeholder="Name" name="c_name" 
                        required>
                </div>
                <div id="input_class" class="input">
                    <input type="text" placeholder=
                        "Constituency" name="c_constituency" required>
                </div>
                <div id="input_year" class="input">
                    <input id="school" type="text" 
                        name="c_party" 
                        placeholder="Party">
                </div>

                **<div id="input_year" class="input">
                    <input id="school" type="file" 
                        name="party_logo" >
                </div>**

                
                <div class="id input">
                    <input id="submit" type="submit" 
                        name="submit" value="submit">
                </div>
            </div>
        </div>

And I'm trying to store this information into a JSON file and I've written the code in NodeJS

 var data = {
        "name": cname,
        "constituency" : cconstituency,
        "party": cparty,

    }

    var data1 = JSON.stringify(data);

    fs.writeFile('detail.json',data1, finished);

I'm able to save the data in JSON file but how can I save the image src in the file?

nidhi_1729
  • 13
  • 2
  • The duplicate us quite old, but hopefully still valid for security reasons. The local path of the file is just none of the webapp's or even server's business – derpirscher May 01 '21 at 17:08

0 Answers0