Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(".Ulozit_upraveny_produkt").click(function() {
- event.preventDefault();
- var pridat_id = $(this).attr('data-produkt-id');
- var form_product = $("#productEdit").serializeArray();
- var files = document.getElementById("file_upload").files;
- var formData = new FormData();
- form_product.forEach(function(item) {
- formData.append(item.name, item.value);
- });
- for (var i = 0; i < files.length; i++) {
- var file = files[i];
- // Add the file to the request.
- formData.append('image[]', file, file.name);
- }
- var xhr = new XMLHttpRequest();
- xhr.open('POST', './library/editProdukty.php', true);
- xhr.onload = function() {
- if (xhr.status === 200) {
- // File(s) uploaded.
- //uploadButton.innerHTML = 'Upload';
- } else {
- alert('Stala se chyba!');
- }
- };
- xhr.send(formData);
- xhr.onreadystatechange = function()
- {
- if (xhr.readyState == 4 && xhr.status == 200)
- {
- console.log(xhr.responseText);
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement