# Send files (Docx, pdf and others) from ionic to a server, is it possible?

**URL:** <https://forum.ionicframework.com/t/send-files-docx-pdf-and-others-from-ionic-to-a-server-is-it-possible/156850>\
**Category:** ionic-v3\
**Created:** [February 19, 2019, 8:28pm UTC](https://forum.ionicframework.com/t/send-files-docx-pdf-and-others-from-ionic-to-a-server-is-it-possible/156850 "2019-02-19T20:28:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego-guevara](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@diego-guevara](https://forum.ionicframework.com/u/diego-guevara)\
**Post date:** [February 19, 2019, 8:28pm UTC](https://forum.ionicframework.com/t/send-files-docx-pdf-and-others-from-ionic-to-a-server-is-it-possible/156850/1 "2019-02-19T20:28:11Z")

</div>

Good day, I am trying to send files (PDF, Docx and others) to a server but I have not yet been able to, I do not find much information about it, I already managed to do it with images. I would like to know if it is possible to do it with files?

I appreciate any help you can give me

regards

---

<div class="post-metadata">

**Author:** ![anna\_liebt](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@anna\_liebt](https://forum.ionicframework.com/u/anna_liebt)\
**Post date:** [February 19, 2019, 10:20pm UTC](https://forum.ionicframework.com/t/send-files-docx-pdf-and-others-from-ionic-to-a-server-is-it-possible/156850/2 "2019-02-19T22:20:11Z")

</div>

Hello,  
yes it is possible. Tecnically is there no difference. Have you access to the routine that process your upload?

Best regards, anna-liebt

---

<div class="post-metadata">

**Author:** ![diego-guevara](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@diego-guevara](https://forum.ionicframework.com/u/diego-guevara)\
**Post date:** [February 21, 2019, 1:16pm UTC](https://forum.ionicframework.com/t/send-files-docx-pdf-and-others-from-ionic-to-a-server-is-it-possible/156850/3 "2019-02-21T13:16:01Z")

</div>

Good morning Anna, thank you very much for your answer, I was trying and finally I could achieve it, this is the code that I use if someone is of help.

uploadresume()  
{  
this.fileChooser.open()  
.then(uri =\>  
{  
/\* ============== inicio file chooser ============== \*/

```
  /*===== verificamos la extension del archivo ========*/
  this.filePath.resolveNativePath(uri)
  .then((filePath) => { 
    let path = filePath.substring(0, filePath.lastIndexOf('/')); // ruta archivo
    let file = filePath.substring(filePath.lastIndexOf('/')+1, filePath.length); // archivo
    
    let archivo = file.split("."); 
    let nombreArchivo = archivo[0];
    let extensionArchivo = archivo[1];

      /* Extensiones validas */
    if(extensionArchivo=="jpg" || extensionArchivo=="pdf" || 
       extensionArchivo=="docx" || extensionArchivo=="xls" || 
       extensionArchivo=="zip" || extensionArchivo=="mp4" || 
       extensionArchivo=="mp3"
       )
      {  

     /*================ cargamos el archivo =============== */
      var archivoUpload ='scripts/registro_upload.php';
      var url = GlobalProvider.baseUrlApi+archivoUpload;

      /* asignamos un nombre al archivo */
       var fecha = new Date();
       var milisegundos = fecha.getTime();
       var nuevoNombreArchivo = "FILE_NEO_"+ milisegundos + "." + extensionArchivo ;
      /* asignamos un nombre al archivo */

      const fileTransfer: FileTransferObject = this.transfer.create();
      let options: FileUploadOptions = {
      fileKey: 'txtFile',
      fileName: nuevoNombreArchivo,
      headers: {},
      params: {"app_key":"Neogestion"},
      chunkedMode : false,
      mimeType: "multipart/form-data"
      }
      fileTransfer.upload(uri, url, options)
      .then((data) => {
      // success
      alert("success"+JSON.stringify(data));
       }, (err) => {
      // error
       alert("error"+JSON.stringify(err));
       });
      /*================ cargamos el archivo =============== */
    }
  }, (err) => {alert("error"+JSON.stringify(err));})
  /*===== verificamos la extension del archivo ========*/

  /* ============== fin filechooser ============== */
})
.catch(e => console.log(e));

```

}

=====================================================================  
registro\_upload.php

\<?php print\_r($\_FILES); /\* ======== recibimos los datos del archivo =============== \*/ $nombreArchivo= $\_FILES['txtFile']['name']; $nombreTemporal = $\_FILES['txtFile']['tmp\_name']; /\* ======== recibimos los datos del archivo =============== \*/ $ruta = '/carpeta/'; if (!file\_exists($ruta)) { mkdir($ruta, 0777, true);} //crea la carpeta en caso de no existir $archivoRenombrado=$ruta.$nombreArchivo; if(isset($archivoRenombrado)) { if(!empty($nombreArchivo)){ if(move\_uploaded\_file($nombreTemporal,$archivoRenombrado)) { } } } ?\>
