Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 10:30

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Multiple Array FromData

Discussion on Multiple Array FromData within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Cc_Cc_Cc's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 418
Received Thanks: 17
Multiple Array FromData

Hey liebe Com,

ich hab ein kleines Problem wobei ich nicht weiterkomme. Hab etwas gegoogelt und bin auf das richtige gestoßen und hab es auch fast geschafft nur eine Sache bekomme ich nicht hin.

Folgendes:

Man kann mehrere Bilder auswählen und dann mit Ajax Senden.

Erstmal mein HTML-Code wo man Bilder auswählen kann:

ganz einfach würde es so gehen:

Quote:
PHP Code:
    $.ajax({
        
type'POST',
        
method'POST',
        
url'../MeetBlog/pages/upload_cache_multiple/upload_cache_multiple.php',
----->        
data: new FormData($(".formphoto2")[0]), <------- 
Da ich jetzt aber noch einen Text eingeben kann und der in einer anderen Form ist muss ich es anders machen.

Das habe ich im Internet gefunden und hab es etwas bearbeitet.

Quote:
PHP Code:
var formData = new FormData();

formData.append('uploadImageMultiple', $('.inputfile')[0].files[0]); 
Jetzt gibt er mir aber kein Array, also habe ich es umgeändert in etwa so:


Problem ist hierbei er sagt mir das es immer nur ein Array gibt. Jetzt frage ich mich was muss in "var arr" rein? So klappt alles jetzt fehlt aber nur noch das er mir immer sagt das es ein array gibt.

Hoffe ihr habt mich Verstanden und könnt mir helfen wäre sehr dankbar
Cc_Cc_Cc is offline  
Old 09/15/2019, 14:06   #2
 
lnqlorlouz's Avatar
 
elite*gold: 0
Join Date: Jun 2013
Posts: 405
Received Thanks: 84
Du gibst ja mit
Code:
$('.inputfile')[0]
auch nur das erste rein. Wie wäre es mit
Code:
var formData = new FormData();
                                    
var arr = document.querySelectorAll('.inputfile'); // liefert dir schon eine iterierbare NodeList, brauchst also kein Array daraus machen
                                    
for(var i = 0; i < arr.length; i++) {
    formData.append('uploadImageMultiple[]', arr[i].files[0]);
}
oder ES6 like:
Code:
const arr = [...document.querySelectorAll(".inputfile"), ...uploadImageMultiple[]];
formData.append(arr);
lnqlorlouz is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Multiple images in multiple Pictureboxes
11/12/2018 - .NET Languages - 4 Replies
Hi epvp, ich hab derzeit ein kleines problemchen und zwar: Ich möchte mehrere Bilder in insgesamt 12 vorgegebenen Pictureboxen laden, nur hab ich kein Plan wie ich dass anstellen soll, vermutlich über eine schleife aber trotzdem bekomm ichs einfach nicht hin... hier mal der Code: #region Bildbearbeitung private void BildOeffnen_Click(object sender, EventArgs e) {
[Selling] WOW account multiple 90's, SC2 CE & Diablo 3 Multiple 60's
05/29/2013 - World of Warcraft Trading - 0 Replies
WTS WOW account multiple 90's, SC2 CE & Diablo 3 Multiple 60's Wow account has a 90 Worgen Druid and a 90 Panda Priest. Gear is nothing 2 notable, priest has season 12 set & a bunch of pve epix. There is also a 82 Tauren Paliden with heirlooms. Priest has Blood Guard title and there is a bunch of rare pets and mounts. Star craft 2 is the collectors edition with all the bonus avatars and watnot. Diablo 3 has a level 60 Monk (25), 60 Wizard (1) and a 60 Hunter (1). All pretty porley...
2 Questions, Selecting multiple coord & multiple inventory items
02/05/2013 - CO2 Private Server - 7 Replies
Need a hand with 2 things ive been tryin to work out but not had much luck so far. 1:Took this example from mining which sets the specific map, But how can you set multiple coords on the map so the action can only been done when standing in those coords rather then the entire map? switch (client.Entity.MapID) { case 1002: {



All times are GMT +1. The time now is 10:31.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.