title: How to upload image to PHP server in Nativescript?
body: <p>I'm trying so long time and there are no effect.
  I have a app in Nativescript and server PHP.
  I'm trying that</p>
  
  <pre><code>function sendImages(fileUri) {
  var request = {
      url: "http://path/to/my/server",
      method: "POST",
      headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          "ENCTYPE":"multipart/form-data",
          "Content-Disposition": "form-data",
          "File-Name": fileUri,
      },
      description: "{uploading:"+fileUri+"}"
  };
  var task = session.uploadFile(fileUri, request);
  return task;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>function sendImages(fileUri){
      var locationRequest = 'http://path/to/my/server';
      var request = new XMLHttpRequest();
      var fs = require("file-system");
      var path = fs.path.normalize(fileUri);
      var file = fs.File.fromPath(path);
      file.readText().then(function(content){
          request.open("POST",locationRequest,true);
          request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  
          request.onload = function(data){
              console.log('success');
          };
          request.onerror = function(data){
              console.log(this.responseText);
              console.log(data);
          };
  
          request.send('fileUri='+content);
      }, function(error){
          alert('error: '+error);
      });
  }
  </code></pre>
  
  <p>and I have somewhere about result in <code>$_POST</code> and <code>$_REQUEST</code> array:</p>
  
  <pre><code>array(11) {
   ["яШяб"]=&gt;
    string(0) ""
    ["'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzѓ„…†‡€‰Љ’“”•–—™љўЈ¤Ґ¦§Ё©ЄІіґµ¶·ё№єВГДЕЖЗИЙКТУФХЦЧШЩЪбвгдежзийкстуфхцчшщъяД"]=&gt;
    string(0) ""
    ["'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ѓ„…†‡€‰Љ’“”•–—™љўЈ¤Ґ¦§Ё©ЄІіґµ¶·ё№єВГДЕЖЗИЙКТУФХЦЧШЩЪвгдежзийктуфхцчшщъяЪ"]=&gt;
    string(0) ""
    ["бПyUљVчЎI4е~ьЦґ№\Zoд
  _лЫЏя"]=&gt;
    string(0) ""
    ["гJMКK^ј­їv*Ri?›hўЉgдБEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEP_J~О±‡‡х
  GсgгЭпЩtЖ·ыMѕущдаџ6y8*¤rq‚OjтЩПАцџю8x{ВЊBKiпјЛЁЫЈЕґ®§ШЄшЧµБDю)ji«iџt«¦ЉНmыRHО¬Y–$oe_2КzЁВwШэsГЬ›'Бd8о,О(*ф°Ь°§MЫ–udЧД›ХGљ-¦¤њdЭ›ЌџAuыFюВЮи~шom}gk\iю…•±юЬЕYыуО}jн‡Ѓbя"]=&gt;
    string(169) "hеHкҐгЦ®йж8zр®ЙРtТ‚ЉkHоУKH№sҐї ±їсЇаПЉѕшЪ_ш—lЁWН±ѕ‰HЋкH3Рс‚ЅЏЁБ;їІOВk?‹я lґmfЬK¦iс5юЈt’4 ,gЩќђэТХпЯµН–•с‹цOУ&gt;0ЫЪЄ\ЩЕi9(“нЋXіиФџъж ђя ‚iЕl|Mв№9lmU}ҐдЭъ…э)"
    ["Ъ;kр6CCЕ,і‚|Ш,Z§€‚’m{7Н/fщµj\–WЧ–IJн6ПЫЧгЦЁъпь(П   ЯµЅ•¤(ъСЃ¶™¤a№`8юR¤Ћ„°оЧМµШ~Р7—_ь]-щ&gt;`свьЗ8U™ХGэтqфв¬Џ€с77ЗgsЏћ*Wцu'J__Fе(Е$Ы¶ЬОЦNR”­vВѕ‚эѓѕ:jѕсдхЛч“HЦK‘І-nЂ$mфWБR?јTъззЪи~НymсkГ3йьОћ І0Њхo"]=&gt;
    string(317) "p)џ5ГщЦ/‡sЄ–ыф¤¤µjйomydЇwM®§{ыk|(Ішaсћk­ФE§k°эєЮ4X¤,DЁ=б» p;WђЧХ?рSЎай‚Џ0ќAIцgя щZ”v&gt;ПЕьв6&gt;ќтЕК3·ч§N3“щКMьфР(ўЉgжЎEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEP¤юИ:х—‡?i/ЯЯИ9.¤¶З&lt;РЙгОЈс®лю
  'б
  KLші§шИДЖПTТ–$—°–"
    ["`ЛнтІДъWПцЧwЭЪLСЛ‡ЋDl2°9Ды'б‡Ж/„_µзГTшUс‰ ѓ]UPСЙ_‰§•AqlЗшъе"]=&gt;
    string(346) "ИБ^Ёэ‡ГмГ.ОxgБшЪсўс5(NzAUЌЇJъsЁЕGOжJтqЊѕ3§G“H°Г;і ЄЈ$“Р_Jш—ю   µвшх7я „;в6ќ5™l§ц”2G"ЏC°0cпЗРWgр§цFш]ы:°ш©сѓЖЦ··y[Йp‚ [W!ЂbLІqтфзўдEР°ЮсЗЧy1Р…&lt;[s­*”Ь#Э№ЩKљЦWIЁфжqWiЯ¬ЗВїШ6ЧАъбЯKa§ЩyDя ЛЗ’ИїЂI?*сџШKв§Ѓю:Е¤кs€нµыF°Зf,#х,»»Х/ЪГцЋЏ,ЉЛAY!рю”МєzH0ЧxiШvИ (&lt;Ѓћ„‘^QУ[L—тґrFБ‘С€*AИ Ћ†„ґ0гЋ/АSг&lt;|ЌуQЛЎF•)6Ъ©м[•Э№]›|®ПЮK™4Ґeнї·oВќCБ_"
    ["сЕµ«fx€    Ј•WеK…P%B}Nып&gt;†јBѕ»ш9ыIь,эЎ|я"]=&gt;
    string(0) ""
    ["WAШy‘†хЪґ“¶Њъ$аXшЃЉџp„ЈUVjUh9Ж5)T•Ь›SiZRMьZ¶щ9ЎЄщ‚ЅЏц!шSЁ|@шСiвimЏцg‡o_f_БgЙ@Ѕјnъ!ц®лБїрMЅyп’_€­"¶RГЈВТ;Ћа&lt;ЃB}v·Тєя"]=&gt;
    string(0) ""
    ["ќЅе¬љM$“sЏ–БA|kвЏЊЮУо‘x~ЗЛ©Иќо?ѓон^
  Sj:ЌюЇЁП«j—rOss3Kq&lt;­–‘Ш’МOrI"]=&gt;
    string(0) ""
    ["Ў¦•‘щqn_в&lt;NkV&lt;®¬®—h¤ЈЯVўў›конЁQEПњ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  (ўЂ
  _д}(ўЂ:­#г§ЖЅПы?GшЇЇБ"]=&gt;
    string(0) ""
  }
  </code></pre>
  
  <p>if I change the "Content-Type" value to "application/octet-stream" or "multipart/form-data" or another, I have empty <code>$_POST</code>, <code>$_GET</code>, <code>$_FILES</code> and <code>$_REQUEST</code>arrays on my server.
  All the same, how I can to upload images on my server PHP?</p>