sandrulis Posted November 26, 2013 Report Share Posted November 26, 2013 (edited) Sveiki! neliela problēma saistībā ar ajax upload. Izmantoju tikai ar javascript failu: (function () { var input = document.getElementById("images"), formdata = false; if (window.FormData) { formdata = new FormData(); document.getElementById("btns").style.display = "none"; } input.addEventListener("change", function (evt) { var i = 0, len = this.files.length, img, reader, file; for ( ; i < len; i++ ) { file = this.files[i]; if (!!file.type.match(/image.*/)) { if ( window.FileReader ) { reader = new FileReader(); reader.onloadend = function (e) { showUploadedItem(e.target.result, file.fileName); }; reader.readAsDataURL(file); } if (formdata) { formdata.append("images[]", file); } } } if (formdata) { $.ajax({ url: "upload.php", type: "POST", data: formdata, processData: false, contentType: false, success: function (html) { $("#images_list").append(html); $('#images').attr({ value: '' }); } }); } }, false); }()); un problēma ir tāda, ka augšuplādējot vienu bildi viss ok, bet kad gribu norādīt vēl vienu tad viņš augšuplādē atkal iepriekšējo un tad atkal norādīto? kur ir problēma? Lai neaugšuplādētu atkal jau iepriekš norādīto attēlu? Ceru ka sapratāt un paldies jau iepriekš P.s. Upload.php fails: <? foreach ($_FILES["images"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $name = $_FILES["images"]["name"][$key]; move_uploaded_file( $_FILES["images"]["tmp_name"][$key], "uploads/" . $_FILES['images']['name'][$key]); print "uploads/" . $_FILES['images']['name'][$key] . "<br>"; } } ?> Edited November 26, 2013 by sandrulis Quote Link to comment Share on other sites More sharing options...
Kavacky Posted November 26, 2013 Report Share Posted November 26, 2013 Pēc uploada aizvāc jau pievienoto. Vai uploado 1x pēc kārtas visas, kad pievienotas visas vajadzīgās. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.