Dealing with file conversion

The following works for all form fields :

function submit(){  

			var formdata = $("#myform").serializeArray();
			var sendJson = JSON.stringify(formdata);
			  var request = $uabjquery.ajax({
							url: 'processResults.php',
							success: function(msg) {  
				 error: function(e){
						alert("Error in Ajax "+e.message);

Now, I want to add few files related HTML stuff inside my form #myform so that I could send it via above function call.

I came across the following link where they are converting the files into base64 format.

Suppose, I have the file related entries in my form now as shown below:

<!-- Start of HTML Form -->
   <form id = "myForm">
   <div class="row" style="margin-bottom: 15px" name="infoRegAttachedDocuments" >
        <div class="col-md-4">
            <label for="docSubmission">First Document</label>
            <input type="file" id="firstdoc">

        <div class="col-md-4">
            <label for="docApproval">Second Document</label>
            <input type="file" id="seconddoc">
        <div class="col-md-4">
            <label for="additionalDocs">Third Document (if any)?</label>
            <input type="file" id="thirdocs">

    <div class="row" style="margin-bottom: 15px" name="infoDiv" >
        <div class="col-md-6">
            <label for="projectTitle">Title </label>
            <input type="text" class="form-control" id="projectTitle" value="<?php echo $previousProjTitle;?>" >
        <div class="col-md-6">
            <label for="projectDesc">Description </label>
            <input type="text" class="form-control" id="projectDesc" value="<?php echo $previousProjDesc;?>">
    <!-- END of HTML Form -->

    <div class="row"style="margin-top: 15px;" >
    <button  class="btn btn-primary" onclick="submit()">Submit</button>

I am wondering , after the button click, is it possible to have all the files gets converted to the base64 format as shown in the example link I mentioned above and have it stored in the formdata variable of var formdata = $("#myform").serializeArray(); so that I could send it via the above Ajax call?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.