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;
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
add a comment |
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
refer stackoverflow.com/questions/32062876/… hope this helps
– Obito Uchiha
Mar 25 at 11:46
add a comment |
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
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
php jquery ajax html5
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
Your remove
function must remove file in e.target.files
or in the p_image[]
tab.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Your remove
function must remove file in e.target.files
or in the p_image[]
tab.
add a comment |
Your remove
function must remove file in e.target.files
or in the p_image[]
tab.
add a comment |
Your remove
function must remove file in e.target.files
or in the p_image[]
tab.
Your remove
function must remove file in e.target.files
or in the p_image[]
tab.
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
refer stackoverflow.com/questions/32062876/… hope this helps
– Obito Uchiha
Mar 25 at 11:46