How to remove image from multiple file uploadRemoving file from multiple files uploader on button click when using HTML5 file inputHow can I upload files asynchronously?How can I select an element with multiple classes in jQuery?Removing multiple classes (jQuery)How do I get a YouTube video thumbnail from the YouTube API?jQuery Ajax File UploadHTML5 File API: get File object within FileReader callbackPreview an image before it is uploadedRemove the last character from stringHow do I return the response from an asynchronous call?FileReader with multi Ajax file upload and progress

What happens when your group is victim of a surprise attack but you can't be surprised?

Why cruise at 7000' in an A319?

Why is C++ initial allocation so much larger than C's?

Architecture of networked game engine

Declining an offer to present a poster instead of a paper

How often can a PC check with passive perception during a combat turn?

How can Charles Proxy change settings without admin rights after first time?

Why aren't (poly-)cotton tents more popular?

Does the Paladin's Aura of Protection affect only either her or ONE ally in range?

C-152 carb heat on before landing in hot weather?

Is there any set of 2-6 notes that doesn't have a chord name?

Intuitively, why does putting capacitors in series decrease the equivalent capacitance?

Procedurally generate regions on island

Symbolic equivalent of chmod 400

What determines the "strength of impact" of a falling object on the ground, momentum or energy?

Should I include salary information on my CV?

Why does Darth Sidious need bodyguards?

What is this blowing instrument used in the acoustic cover of "Taekwondo" by "Walk off the Earth"?

Should I tell my insurance company I'm making payments on my new car?

How to append a matrix element by element?

Using symmetry of Riemann tensor to vanish components

Are Finite Automata Turing Complete?

Why isn’t the tax system continuous rather than bracketed?

Why do some games show lights shine through walls?



How to remove image from multiple file upload


Removing file from multiple files uploader on button click when using HTML5 file inputHow can I upload files asynchronously?How can I select an element with multiple classes in jQuery?Removing multiple classes (jQuery)How do I get a YouTube video thumbnail from the YouTube API?jQuery Ajax File UploadHTML5 File API: get File object within FileReader callbackPreview an image before it is uploadedRemove the last character from stringHow do I return the response from an asynchronous call?FileReader with multi Ajax file upload and progress






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have created multiple image upload function with preview and remove option. But when i select files ,suppose 4 images and then it previews 4 images correctly. Now i remove 2 of them from preview and try to upload in database but it still uploading 4 images instead of 2 image.



$(document).ready(function() 
if (window.File && window.FileList && window.FileReader)
$("#vpb-data-file").on("change", function(e)
var files = e.target.files,
filesLength = files.length;

for (var i = 0; i < filesLength; i++)
var f = files[i]
var fileReader = new FileReader();

fileReader.onload = (function(e)
var file = e.target;
$("<span class="pip">" +
"<img class="imageThumb" height="100" width="100" src="" + e.target.result + "" title="" + file.name + ""/>" +
"<br/><span class="remove">Remove</span>" +
"</span>").insertAfter("#ml_image");

$(".remove").click(function()
$(this).parent(".pip").remove();
);

// Old code here
/*$("<img></img>",
class: "imageThumb",
src: e.target.result,
title: file.name + " ).insertAfter("#files").click(function()
$(this).remove();
);*/
);
fileReader.readAsDataURL(f);

);
else
alert("Your browser doesn't support to File API")

);


<div class="card-body">
<div class="row" id="ml_image" style="margin-top:15px;">
<div class="col-md-3">
<label class="form-label">Upload Image<br>
<span style="font-size:12px;">(For multiple images press ctrl.)</span>
</label>
</div>
<div class="col-md-6">
<span onclick="product_image();" id="hide_span" class="btn btn-icon btn-primary file_upload_icon" style="margin-top:6px;"><i class="fas fa-cloud-upload-alt" style="font-size:31px;"></i><strong style="color:#000000;padding:10px;font-size:15px;">Choose File...</strong></span><input
style="display:none;" type="file" name="p_image[]" id="vpb-data-file" multiple />
</div>
</div>
<div class="row" id="vpb-display-preview"></div>
</div>


$p_image = count($_FILES['p_image']['name']);
print_r($p_image);


Here I am counting how many files I want to upload. I am getting 4 instead of 2.










share|improve this question
























  • refer stackoverflow.com/questions/32062876/… hope this helps

    – Obito Uchiha
    Mar 25 at 11:46


















1















I have created multiple image upload function with preview and remove option. But when i select files ,suppose 4 images and then it previews 4 images correctly. Now i remove 2 of them from preview and try to upload in database but it still uploading 4 images instead of 2 image.



$(document).ready(function() 
if (window.File && window.FileList && window.FileReader)
$("#vpb-data-file").on("change", function(e)
var files = e.target.files,
filesLength = files.length;

for (var i = 0; i < filesLength; i++)
var f = files[i]
var fileReader = new FileReader();

fileReader.onload = (function(e)
var file = e.target;
$("<span class="pip">" +
"<img class="imageThumb" height="100" width="100" src="" + e.target.result + "" title="" + file.name + ""/>" +
"<br/><span class="remove">Remove</span>" +
"</span>").insertAfter("#ml_image");

$(".remove").click(function()
$(this).parent(".pip").remove();
);

// Old code here
/*$("<img></img>",
class: "imageThumb",
src: e.target.result,
title: file.name + " ).insertAfter("#files").click(function()
$(this).remove();
);*/
);
fileReader.readAsDataURL(f);

);
else
alert("Your browser doesn't support to File API")

);


<div class="card-body">
<div class="row" id="ml_image" style="margin-top:15px;">
<div class="col-md-3">
<label class="form-label">Upload Image<br>
<span style="font-size:12px;">(For multiple images press ctrl.)</span>
</label>
</div>
<div class="col-md-6">
<span onclick="product_image();" id="hide_span" class="btn btn-icon btn-primary file_upload_icon" style="margin-top:6px;"><i class="fas fa-cloud-upload-alt" style="font-size:31px;"></i><strong style="color:#000000;padding:10px;font-size:15px;">Choose File...</strong></span><input
style="display:none;" type="file" name="p_image[]" id="vpb-data-file" multiple />
</div>
</div>
<div class="row" id="vpb-display-preview"></div>
</div>


$p_image = count($_FILES['p_image']['name']);
print_r($p_image);


Here I am counting how many files I want to upload. I am getting 4 instead of 2.










share|improve this question
























  • refer stackoverflow.com/questions/32062876/… hope this helps

    – Obito Uchiha
    Mar 25 at 11:46














1












1








1








I have created multiple image upload function with preview and remove option. But when i select files ,suppose 4 images and then it previews 4 images correctly. Now i remove 2 of them from preview and try to upload in database but it still uploading 4 images instead of 2 image.



$(document).ready(function() 
if (window.File && window.FileList && window.FileReader)
$("#vpb-data-file").on("change", function(e)
var files = e.target.files,
filesLength = files.length;

for (var i = 0; i < filesLength; i++)
var f = files[i]
var fileReader = new FileReader();

fileReader.onload = (function(e)
var file = e.target;
$("<span class="pip">" +
"<img class="imageThumb" height="100" width="100" src="" + e.target.result + "" title="" + file.name + ""/>" +
"<br/><span class="remove">Remove</span>" +
"</span>").insertAfter("#ml_image");

$(".remove").click(function()
$(this).parent(".pip").remove();
);

// Old code here
/*$("<img></img>",
class: "imageThumb",
src: e.target.result,
title: file.name + " ).insertAfter("#files").click(function()
$(this).remove();
);*/
);
fileReader.readAsDataURL(f);

);
else
alert("Your browser doesn't support to File API")

);


<div class="card-body">
<div class="row" id="ml_image" style="margin-top:15px;">
<div class="col-md-3">
<label class="form-label">Upload Image<br>
<span style="font-size:12px;">(For multiple images press ctrl.)</span>
</label>
</div>
<div class="col-md-6">
<span onclick="product_image();" id="hide_span" class="btn btn-icon btn-primary file_upload_icon" style="margin-top:6px;"><i class="fas fa-cloud-upload-alt" style="font-size:31px;"></i><strong style="color:#000000;padding:10px;font-size:15px;">Choose File...</strong></span><input
style="display:none;" type="file" name="p_image[]" id="vpb-data-file" multiple />
</div>
</div>
<div class="row" id="vpb-display-preview"></div>
</div>


$p_image = count($_FILES['p_image']['name']);
print_r($p_image);


Here I am counting how many files I want to upload. I am getting 4 instead of 2.










share|improve this question
















I have created multiple image upload function with preview and remove option. But when i select files ,suppose 4 images and then it previews 4 images correctly. Now i remove 2 of them from preview and try to upload in database but it still uploading 4 images instead of 2 image.



$(document).ready(function() 
if (window.File && window.FileList && window.FileReader)
$("#vpb-data-file").on("change", function(e)
var files = e.target.files,
filesLength = files.length;

for (var i = 0; i < filesLength; i++)
var f = files[i]
var fileReader = new FileReader();

fileReader.onload = (function(e)
var file = e.target;
$("<span class="pip">" +
"<img class="imageThumb" height="100" width="100" src="" + e.target.result + "" title="" + file.name + ""/>" +
"<br/><span class="remove">Remove</span>" +
"</span>").insertAfter("#ml_image");

$(".remove").click(function()
$(this).parent(".pip").remove();
);

// Old code here
/*$("<img></img>",
class: "imageThumb",
src: e.target.result,
title: file.name + " ).insertAfter("#files").click(function()
$(this).remove();
);*/
);
fileReader.readAsDataURL(f);

);
else
alert("Your browser doesn't support to File API")

);


<div class="card-body">
<div class="row" id="ml_image" style="margin-top:15px;">
<div class="col-md-3">
<label class="form-label">Upload Image<br>
<span style="font-size:12px;">(For multiple images press ctrl.)</span>
</label>
</div>
<div class="col-md-6">
<span onclick="product_image();" id="hide_span" class="btn btn-icon btn-primary file_upload_icon" style="margin-top:6px;"><i class="fas fa-cloud-upload-alt" style="font-size:31px;"></i><strong style="color:#000000;padding:10px;font-size:15px;">Choose File...</strong></span><input
style="display:none;" type="file" name="p_image[]" id="vpb-data-file" multiple />
</div>
</div>
<div class="row" id="vpb-display-preview"></div>
</div>


$p_image = count($_FILES['p_image']['name']);
print_r($p_image);


Here I am counting how many files I want to upload. I am getting 4 instead of 2.







php jquery ajax html5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 11:17









Rory McCrossan

256k29 gold badges221 silver badges260 bronze badges




256k29 gold badges221 silver badges260 bronze badges










asked Mar 25 at 11:15









Sujit SarkarSujit Sarkar

91 bronze badge




91 bronze badge












  • refer stackoverflow.com/questions/32062876/… hope this helps

    – Obito Uchiha
    Mar 25 at 11:46


















  • refer stackoverflow.com/questions/32062876/… hope this helps

    – Obito Uchiha
    Mar 25 at 11:46

















refer stackoverflow.com/questions/32062876/… hope this helps

– Obito Uchiha
Mar 25 at 11:46






refer stackoverflow.com/questions/32062876/… hope this helps

– Obito Uchiha
Mar 25 at 11:46













1 Answer
1






active

oldest

votes


















0














Your remove function must remove file in e.target.files or in the p_image[] tab.






share|improve this answer



























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336569%2fhow-to-remove-image-from-multiple-file-upload%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Your remove function must remove file in e.target.files or in the p_image[] tab.






    share|improve this answer





























      0














      Your remove function must remove file in e.target.files or in the p_image[] tab.






      share|improve this answer



























        0












        0








        0







        Your remove function must remove file in e.target.files or in the p_image[] tab.






        share|improve this answer















        Your remove function must remove file in e.target.files or in the p_image[] tab.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 14 at 4:52









        NIMISHAN

        9761 gold badge13 silver badges23 bronze badges




        9761 gold badge13 silver badges23 bronze badges










        answered Mar 25 at 11:33









        Guillaume QuarréGuillaume Quarré

        1




        1





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336569%2fhow-to-remove-image-from-multiple-file-upload%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript