Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Progress bar
bmati666
post 9.03.2016, 15:37:01
Post #1





Grupa: Zarejestrowani
Postów: 57
Pomógł: 1
Dołączył: 12.02.2016

Ostrzeżenie: (0%)
-----


Witam,
Znalazłem taki skrypt

  1. function _(el){
  2. return document.getElementById(el);
  3. }
  4. function uploadFile(){
  5. var file = _("file1").files[0];
  6. var formdata = new FormData();
  7. formdata.append("file1", file);
  8. var ajax = new XMLHttpRequest();
  9. ajax.upload.addEventListener("progress", progressHandler, false);
  10. ajax.addEventListener("load", completeHandler, false);
  11. ajax.addEventListener("error", errorHandler, false);
  12. ajax.addEventListener("abort", abortHandler, false);
  13. ajax.open("POST", "file_upload_parser.php");
  14. ajax.send(formdata);
  15. }
  16. function progressHandler(event){
  17. _("loaded_n_total").innerHTML = "Uploaded "+event.loaded+" bytes of "+event.total;
  18. var percent = (event.loaded / event.total) * 100;
  19. _("progressBar").value = Math.round(percent);
  20. _("status").innerHTML = Math.round(percent)+"% uploaded... please wait";
  21. }
  22. function completeHandler(event){
  23. _("status").innerHTML = event.target.responseText;
  24. _("progressBar").value = 0;
  25. }
  26. function errorHandler(event){
  27. _("status").innerHTML = "Upload Failed";
  28. }
  29. function abortHandler(event){
  30. _("status").innerHTML = "Upload Aborted";
  31. }


ale chciałbym, żeby do pliku file_upload_parser.php przesyłało też tekst wpisany w inpucie.
Da się to zrobić?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
nospor
post 9.03.2016, 15:47:42
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




https://developer.mozilla.org/en/docs/Web/API/FormData
Musisz poprostu zrobic set() na formdata. Przenosze boto nie ma zadnego zwiazku z php


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 31.07.2025 - 10:43